mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219186 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user