Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GlobalISel][AArch64] Add support for base register + offset register…
… loads Add support for folding G_GEPs into loads of the form ``` ldr reg, [base, off] ``` when possible. This can save an add before the load. Currently, this is only supported for loads of 64 bits into 64 bit registers. Add a new addressing mode function, `selectAddrModeRegisterOffset` which performs this folding when it is profitable. Also add a test for addressing modes for G_LOAD. Differential Revision: https://reviews.llvm.org/D64944 llvm-svn: 366503
- Loading branch information
Jessica Paquette
committed
Jul 18, 2019
1 parent
50057f3
commit 7a1dcc5
Showing
2 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
llvm/test/CodeGen/AArch64/GlobalISel/load-addressing-modes.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=aarch64-unknown-unknown -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | | ||
define void @ldrxrox_breg_oreg(i64* %addr) { ret void } | ||
define void @ldrdrox_breg_oreg(i64* %addr) { ret void } | ||
define void @more_than_one_use(i64* %addr) { ret void } | ||
... | ||
|
||
--- | ||
name: ldrxrox_breg_oreg | ||
alignment: 2 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
machineFunctionInfo: {} | ||
body: | | ||
bb.0: | ||
liveins: $x0, $x1 | ||
; CHECK-LABEL: name: ldrxrox_breg_oreg | ||
; CHECK: liveins: $x0, $x1 | ||
; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0 | ||
; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 | ||
; CHECK: [[LDRXroX:%[0-9]+]]:gpr64 = LDRXroX [[COPY]], [[COPY1]], 0, 0 :: (load 8 from %ir.addr) | ||
; CHECK: $x0 = COPY [[LDRXroX]] | ||
; CHECK: RET_ReallyLR implicit $x0 | ||
%0:gpr(p0) = COPY $x0 | ||
%1:gpr(s64) = COPY $x1 | ||
%2:gpr(p0) = G_GEP %0, %1 | ||
%4:gpr(s64) = G_LOAD %2(p0) :: (load 8 from %ir.addr) | ||
$x0 = COPY %4(s64) | ||
RET_ReallyLR implicit $x0 | ||
... | ||
|
||
--- | ||
name: ldrdrox_breg_oreg | ||
alignment: 2 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
machineFunctionInfo: {} | ||
body: | | ||
bb.0: | ||
liveins: $d0, $x1 | ||
; CHECK-LABEL: name: ldrdrox_breg_oreg | ||
; CHECK: liveins: $d0, $x1 | ||
; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $d0 | ||
; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 | ||
; CHECK: [[LDRDroX:%[0-9]+]]:fpr64 = LDRDroX [[COPY]], [[COPY1]], 0, 0 :: (load 8 from %ir.addr) | ||
; CHECK: $d0 = COPY [[LDRDroX]] | ||
; CHECK: RET_ReallyLR implicit $d0 | ||
%0:gpr(p0) = COPY $d0 | ||
%1:gpr(s64) = COPY $x1 | ||
%2:gpr(p0) = G_GEP %0, %1 | ||
%4:fpr(s64) = G_LOAD %2(p0) :: (load 8 from %ir.addr) | ||
$d0 = COPY %4(s64) | ||
RET_ReallyLR implicit $d0 | ||
... | ||
|
||
--- | ||
name: more_than_one_use | ||
alignment: 2 | ||
legalized: true | ||
regBankSelected: true | ||
tracksRegLiveness: true | ||
machineFunctionInfo: {} | ||
body: | | ||
bb.0: | ||
liveins: $x0, $x1 | ||
; This shouldn't be folded, since we reuse the result of the G_GEP outside | ||
; the G_LOAD | ||
; CHECK-LABEL: name: more_than_one_use | ||
; CHECK: liveins: $x0, $x1 | ||
; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 | ||
; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1 | ||
; CHECK: [[ADDXrr:%[0-9]+]]:gpr64common = ADDXrr [[COPY]], [[COPY1]] | ||
; CHECK: [[LDRXui:%[0-9]+]]:gpr64 = LDRXui [[ADDXrr]], 0 :: (load 8 from %ir.addr) | ||
; CHECK: [[COPY2:%[0-9]+]]:gpr64 = COPY [[ADDXrr]] | ||
; CHECK: [[ADDXrr1:%[0-9]+]]:gpr64 = ADDXrr [[COPY2]], [[LDRXui]] | ||
; CHECK: $x0 = COPY [[ADDXrr1]] | ||
; CHECK: RET_ReallyLR implicit $x0 | ||
%0:gpr(p0) = COPY $x0 | ||
%1:gpr(s64) = COPY $x1 | ||
%2:gpr(p0) = G_GEP %0, %1 | ||
%4:gpr(s64) = G_LOAD %2(p0) :: (load 8 from %ir.addr) | ||
%5:gpr(s64) = G_PTRTOINT %2 | ||
%6:gpr(s64) = G_ADD %5, %4 | ||
$x0 = COPY %6(s64) | ||
RET_ReallyLR implicit $x0 |