[llvm] r214545 - [FastISel][AArch64] Fold offset into the memory operation.
Juergen Ributzka
juergen at apple.com
Fri Aug 1 12:40:16 PDT 2014
Author: ributzka
Date: Fri Aug 1 14:40:16 2014
New Revision: 214545
URL: http://llvm.org/viewvc/llvm-project?rev=214545&view=rev
Log:
[FastISel][AArch64] Fold offset into the memory operation.
Fold simple offsets into the memory operation:
add x0, x0, #8
ldr x0, [x0]
-->
ldr x0, [x0, #8]
Fixes <rdar://problem/17887945>.
Added:
llvm/trunk/test/CodeGen/AArch64/fast-isel-compute-address.ll
Modified:
llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
Modified: llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp?rev=214545&r1=214544&r2=214545&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp Fri Aug 1 14:40:16 2014
@@ -419,6 +419,13 @@ bool AArch64FastISel::ComputeAddress(con
}
break;
}
+ case Instruction::Add:
+ // Adds of constants are common and easy enough.
+ if (const ConstantInt *CI = dyn_cast<ConstantInt>(U->getOperand(1))) {
+ Addr.setOffset(Addr.getOffset() + (uint64_t)CI->getSExtValue());
+ return ComputeAddress(U->getOperand(0), Addr);
+ }
+ break;
}
// Try to get this in a register if nothing else has worked.
Added: llvm/trunk/test/CodeGen/AArch64/fast-isel-compute-address.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fast-isel-compute-address.ll?rev=214545&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/fast-isel-compute-address.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/fast-isel-compute-address.ll Fri Aug 1 14:40:16 2014
@@ -0,0 +1,23 @@
+; RUN: llc -fast-isel -fast-isel-abort -mtriple=arm64-apple-darwin < %s | FileCheck %s
+
+; Test simple constant offset.
+define i64 @test_load1(i64 %a) {
+; CHECK-LABEL: test_load1
+; CHECK: ldr x0, [x0, #16]
+ %1 = add i64 %a, 16
+ %2 = inttoptr i64 %1 to i64*
+ %3 = load i64* %2
+ ret i64 %3
+}
+
+; Test large constant offset.
+define i64 @test_load2(i64 %a) {
+; CHECK-LABEL: test_load2
+; CHECK: add [[REG:x[0-9]+]], x0, {{x[0-9]+}}
+; CHECK: ldr x0, {{\[}}[[REG]]{{\]}}
+ %1 = add i64 %a, 16777216
+ %2 = inttoptr i64 %1 to i64*
+ %3 = load i64* %2
+ ret i64 %3
+}
+
More information about the llvm-commits
mailing list