mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 06:09:05 +00:00
indvars -disable-iv-rewrite: handle an edge case involving identity phis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134124 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5244c4cc2f
commit
60ac719c85
@ -1015,9 +1015,9 @@ bool IndVarSimplify::EliminateIVUser(Instruction *UseInst,
|
||||
(SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
|
||||
return false;
|
||||
|
||||
UseInst->replaceAllUsesWith(IVOperand);
|
||||
|
||||
DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n');
|
||||
|
||||
UseInst->replaceAllUsesWith(IVOperand);
|
||||
++NumElimIdentity;
|
||||
Changed = true;
|
||||
DeadInsts.push_back(UseInst);
|
||||
@ -1037,7 +1037,9 @@ static void pushIVUsers(
|
||||
|
||||
// Avoid infinite or exponential worklist processing.
|
||||
// Also ensure unique worklist users.
|
||||
if (Simplified.insert(User))
|
||||
// If Def is a LoopPhi, it may not be in the Simplified set, so check for
|
||||
// self edges first.
|
||||
if (User != Def && Simplified.insert(User))
|
||||
SimpleIVUsers.push_back(std::make_pair(User, Def));
|
||||
}
|
||||
}
|
||||
@ -1111,6 +1113,9 @@ void IndVarSimplify::SimplifyIVUsersNoRewrite(Loop *L, SCEVExpander &Rewriter) {
|
||||
// Use-def pairs if IVUsers waiting to be processed for CurrIV.
|
||||
SmallVector<std::pair<Instruction*, Instruction*>, 8> SimpleIVUsers;
|
||||
|
||||
// Push users of the current LoopPhi. In rare cases, pushIVUsers may be
|
||||
// called multiple times for the same LoopPhi. This is the proper thing to
|
||||
// do for loop header phis that use each other.
|
||||
pushIVUsers(CurrIV, Simplified, SimpleIVUsers);
|
||||
|
||||
while (!SimpleIVUsers.empty()) {
|
||||
|
@ -23,7 +23,7 @@ ph:
|
||||
; sext should be eliminated while preserving gep inboundsness.
|
||||
; CHECK-NOT: sext
|
||||
; CHECK: getelementptr inbounds
|
||||
; CHECK: exit
|
||||
; CHECK: exit:
|
||||
loop:
|
||||
%i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
|
||||
%s.01 = phi i32 [ 0, %ph ], [ %sinc, %loop ]
|
||||
@ -64,7 +64,7 @@ ph:
|
||||
; CHECK: getelementptr inbounds
|
||||
; %vall sext should obviously not be eliminated
|
||||
; CHECK: sext
|
||||
; CHECK: exit
|
||||
; CHECK: exit:
|
||||
loop:
|
||||
%i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
|
||||
%s.01 = phi i64 [ 0, %ph ], [ %sinc, %loop ]
|
||||
@ -108,7 +108,7 @@ ph:
|
||||
; Preserve gep inboundsness, and don't factor it.
|
||||
; CHECK: getelementptr inbounds i32* %ptriv, i32 1
|
||||
; CHECK-NOT: add
|
||||
; CHECK: exit
|
||||
; CHECK: exit:
|
||||
loop:
|
||||
%ptriv = phi i32* [ %first, %ph ], [ %ptrpost, %loop ]
|
||||
%ofs = sext i32 %idx to i64
|
||||
@ -139,7 +139,7 @@ entry:
|
||||
; CHECK: phi i32
|
||||
; CHECK: bitcast
|
||||
; CHECK: getelementptr
|
||||
; CHECK: exit
|
||||
; CHECK: exit:
|
||||
loop:
|
||||
%iv = phi i32 [%start, %entry], [%next, %loop]
|
||||
%p = phi %struct* [%base, %entry], [%pinc, %loop]
|
||||
@ -157,12 +157,13 @@ exit:
|
||||
}
|
||||
|
||||
define void @maxvisitor(i32 %limit, i32* %base) nounwind {
|
||||
entry: br label %loop
|
||||
entry:
|
||||
br label %loop
|
||||
|
||||
; CHECK: loop:
|
||||
; CHECK: phi i64
|
||||
; CHECK: trunc
|
||||
; CHECK: exit
|
||||
; CHECK: exit:
|
||||
loop:
|
||||
%idx = phi i32 [ 0, %entry ], [ %idx.next, %loop.inc ]
|
||||
%max = phi i32 [ 0, %entry ], [ %max.next, %loop.inc ]
|
||||
@ -186,4 +187,28 @@ loop.inc:
|
||||
|
||||
exit:
|
||||
ret void
|
||||
}
|
||||
}
|
||||
|
||||
; CHECK: loop:
|
||||
; CHECK: phi i32
|
||||
; CHECK-NOT: phi
|
||||
; CHECK: exit:
|
||||
define void @identityphi(i32 %limit) nounwind {
|
||||
entry:
|
||||
br label %loop
|
||||
|
||||
loop:
|
||||
%iv = phi i32 [ 0, %entry], [ %iv.next, %control ]
|
||||
br i1 undef, label %if.then, label %control
|
||||
|
||||
if.then:
|
||||
br label %control
|
||||
|
||||
control:
|
||||
%iv.next = phi i32 [ %iv, %loop ], [ undef, %if.then ]
|
||||
%cmp = icmp slt i32 %iv.next, %limit
|
||||
br i1 %cmp, label %loop, label %exit
|
||||
|
||||
exit:
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user