summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-10-07 03:40:03 +0000
committerJuergen Ributzka <juergen@apple.com>2014-10-07 03:40:03 +0000
commit75b2f340692f12fea7ce9a7e3021423ce41c8f9e (patch)
tree49234560e56320dc08c5b275d9f583a66abb056a /llvm/lib
parent42bf665f2bcb23525f07d054db001b3bcd3466bb (diff)
downloadbcm5719-llvm-75b2f340692f12fea7ce9a7e3021423ce41c8f9e.tar.gz
bcm5719-llvm-75b2f340692f12fea7ce9a7e3021423ce41c8f9e.zip
[FastISel][AArch64] Teach the address computation to also fold sub instructions.
Tiny enhancement to the address computation code to also fold sub instructions if the rhs is constant and can be folded into the offset. llvm-svn: 219186
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AArch64/AArch64FastISel.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
index 504049bbafd..559a6bdf8ea 100644
--- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
@@ -590,7 +590,7 @@ bool AArch64FastISel::computeAddress(const Value *Obj, Address &Addr, Type *Ty)
std::swap(LHS, RHS);
if (const ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
- Addr.setOffset(Addr.getOffset() + (uint64_t)CI->getSExtValue());
+ Addr.setOffset(Addr.getOffset() + CI->getSExtValue());
return computeAddress(LHS, Addr, Ty);
}
@@ -601,6 +601,17 @@ bool AArch64FastISel::computeAddress(const Value *Obj, Address &Addr, Type *Ty)
break;
}
+ case Instruction::Sub: {
+ // Subs of constants are common and easy enough.
+ const Value *LHS = U->getOperand(0);
+ const Value *RHS = U->getOperand(1);
+
+ if (const ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
+ Addr.setOffset(Addr.getOffset() - CI->getSExtValue());
+ return computeAddress(LHS, Addr, Ty);
+ }
+ break;
+ }
case Instruction::Shl: {
if (Addr.getOffsetReg())
break;
OpenPOWER on IntegriCloud