mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
AArch64: be careful of large immediates when optimising cmps.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -154,11 +154,18 @@ MachineInstr *AArch64ConditionOptimizer::findSuitableCompare(
|
|||||||
// cmn is an alias for adds with a dead destination register.
|
// cmn is an alias for adds with a dead destination register.
|
||||||
case AArch64::ADDSWri:
|
case AArch64::ADDSWri:
|
||||||
case AArch64::ADDSXri:
|
case AArch64::ADDSXri:
|
||||||
if (MRI->use_empty(I->getOperand(0).getReg()))
|
if (!I->getOperand(2).isImm()) {
|
||||||
return I;
|
DEBUG(dbgs() << "Immediate of cmp is symbolic, " << *I << '\n');
|
||||||
|
return nullptr;
|
||||||
DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n');
|
} else if (I->getOperand(2).getImm() << I->getOperand(3).getImm() >=
|
||||||
return nullptr;
|
0xfff) {
|
||||||
|
DEBUG(dbgs() << "Immediate of cmp may be out of range, " << *I << '\n');
|
||||||
|
return nullptr;
|
||||||
|
} else if (!MRI->use_empty(I->getOperand(0).getReg())) {
|
||||||
|
DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n');
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return I;
|
||||||
|
|
||||||
// Prevent false positive case like:
|
// Prevent false positive case like:
|
||||||
// cmp w19, #0
|
// cmp w19, #0
|
||||||
|
|||||||
@@ -403,6 +403,32 @@ return: ; preds = %land.lhs.true, %con
|
|||||||
ret i32 %retval.0
|
ret i32 %retval.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define void @cmp_shifted(i32 %in, i32 %lhs, i32 %rhs) {
|
||||||
|
; CHECK-LABEL: cmp_shifted:
|
||||||
|
; CHECK: cmp w0, #1
|
||||||
|
; [...]
|
||||||
|
; CHECK: cmp w0, #2, lsl #12
|
||||||
|
|
||||||
|
%tst_low = icmp sgt i32 %in, 0
|
||||||
|
br i1 %tst_low, label %true, label %false
|
||||||
|
|
||||||
|
true:
|
||||||
|
call i32 @zoo(i32 128)
|
||||||
|
ret void
|
||||||
|
|
||||||
|
false:
|
||||||
|
%tst = icmp sgt i32 %in, 8191
|
||||||
|
br i1 %tst, label %truer, label %falser
|
||||||
|
|
||||||
|
truer:
|
||||||
|
call i32 @zoo(i32 42)
|
||||||
|
ret void
|
||||||
|
|
||||||
|
falser:
|
||||||
|
call i32 @zoo(i32 1)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
declare i32 @zoo(i32)
|
declare i32 @zoo(i32)
|
||||||
|
|
||||||
declare double @yoo(i32)
|
declare double @yoo(i32)
|
||||||
|
|||||||
Reference in New Issue
Block a user