diff options
| author | Juergen Ributzka <juergen@apple.com> | 2014-10-07 03:40:03 +0000 |
|---|---|---|
| committer | Juergen Ributzka <juergen@apple.com> | 2014-10-07 03:40:03 +0000 |
| commit | 75b2f340692f12fea7ce9a7e3021423ce41c8f9e (patch) | |
| tree | 49234560e56320dc08c5b275d9f583a66abb056a /llvm/lib | |
| parent | 42bf665f2bcb23525f07d054db001b3bcd3466bb (diff) | |
| download | bcm5719-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.cpp | 13 |
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; |

