mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
Do not simplifyLatch for loops where hoisting increments couldresult in extra live range interferance
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3262c451c4
commit
a5ca5d9f82
@ -194,8 +194,13 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader,
|
|||||||
/// heuristics. We handle a single arithmetic instruction along with any type
|
/// heuristics. We handle a single arithmetic instruction along with any type
|
||||||
/// conversions.
|
/// conversions.
|
||||||
static bool shouldSpeculateInstrs(BasicBlock::iterator Begin,
|
static bool shouldSpeculateInstrs(BasicBlock::iterator Begin,
|
||||||
BasicBlock::iterator End) {
|
BasicBlock::iterator End, Loop *L) {
|
||||||
bool seenIncrement = false;
|
bool seenIncrement = false;
|
||||||
|
bool MultiExitLoop = false;
|
||||||
|
|
||||||
|
if (!L->getExitingBlock())
|
||||||
|
MultiExitLoop = true;
|
||||||
|
|
||||||
for (BasicBlock::iterator I = Begin; I != End; ++I) {
|
for (BasicBlock::iterator I = Begin; I != End; ++I) {
|
||||||
|
|
||||||
if (!isSafeToSpeculativelyExecute(I))
|
if (!isSafeToSpeculativelyExecute(I))
|
||||||
@ -219,11 +224,33 @@ static bool shouldSpeculateInstrs(BasicBlock::iterator Begin,
|
|||||||
case Instruction::Xor:
|
case Instruction::Xor:
|
||||||
case Instruction::Shl:
|
case Instruction::Shl:
|
||||||
case Instruction::LShr:
|
case Instruction::LShr:
|
||||||
case Instruction::AShr:
|
case Instruction::AShr: {
|
||||||
|
Value *IVOpnd = nullptr;
|
||||||
|
if (isa<ConstantInt>(I->getOperand(0)))
|
||||||
|
IVOpnd = I->getOperand(1);
|
||||||
|
|
||||||
|
if (isa<ConstantInt>(I->getOperand(1))) {
|
||||||
|
if (IVOpnd)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IVOpnd = I->getOperand(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If increment operand is used outside of the loop, this speculation
|
||||||
|
// could cause extra live range interference.
|
||||||
|
if (MultiExitLoop && IVOpnd) {
|
||||||
|
for (User *UseI : IVOpnd->users()) {
|
||||||
|
auto *UserInst = cast<Instruction>(UseI);
|
||||||
|
if (!L->contains(UserInst))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (seenIncrement)
|
if (seenIncrement)
|
||||||
return false;
|
return false;
|
||||||
seenIncrement = true;
|
seenIncrement = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Instruction::Trunc:
|
case Instruction::Trunc:
|
||||||
case Instruction::ZExt:
|
case Instruction::ZExt:
|
||||||
case Instruction::SExt:
|
case Instruction::SExt:
|
||||||
@ -259,7 +286,7 @@ bool LoopRotate::simplifyLoopLatch(Loop *L) {
|
|||||||
if (!BI)
|
if (!BI)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!shouldSpeculateInstrs(Latch->begin(), Jmp))
|
if (!shouldSpeculateInstrs(Latch->begin(), Jmp, L))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DEBUG(dbgs() << "Folding loop latch " << Latch->getName() << " into "
|
DEBUG(dbgs() << "Folding loop latch " << Latch->getName() << " into "
|
||||||
|
@ -46,9 +46,9 @@ define void @FindFreeHorzSeg(i64 %startCol, i64 %row, i64* %rowStart) {
|
|||||||
; CHECK-LABEL: define void @FindFreeHorzSeg(
|
; CHECK-LABEL: define void @FindFreeHorzSeg(
|
||||||
; CHECK: %dec = add
|
; CHECK: %dec = add
|
||||||
; CHECK-NEXT: tail call void @llvm.dbg.value
|
; CHECK-NEXT: tail call void @llvm.dbg.value
|
||||||
; CHECK-NEXT: br i1 %tobool, label %for.cond, label %[[LOOP_EXIT:[^,]*]]
|
; CHECK: %cmp = icmp
|
||||||
; CHECK: [[LOOP_EXIT]]:
|
; CHECK: br i1 %cmp
|
||||||
; CHECK-NEXT: phi i64 [ %{{[^,]*}}, %{{[^,]*}} ]
|
; CHECK: phi i64 [ %{{[^,]*}}, %{{[^,]*}} ]
|
||||||
; CHECK-NEXT: br label %for.end
|
; CHECK-NEXT: br label %for.end
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
@mode_table = global [4 x i32] zeroinitializer ; <[4 x i32]*> [#uses=1]
|
@mode_table = global [4 x i32] zeroinitializer ; <[4 x i32]*> [#uses=1]
|
||||||
|
|
||||||
; CHECK-LABEL: @f(
|
; CHECK-LABEL: @f(
|
||||||
; CHECK-NOT: bb4
|
; CHECK-NOT: bb:
|
||||||
define i8 @f() {
|
define i8 @f() {
|
||||||
entry:
|
entry:
|
||||||
tail call i32 @fegetround( ) ; <i32>:0 [#uses=1]
|
tail call i32 @fegetround( ) ; <i32>:0 [#uses=1]
|
||||||
|
Loading…
Reference in New Issue
Block a user