[LoopSimplify] When simplifying phis in loop-simplify, do it only if it preserves LCSSA form.
llvm-svn: 282541
This commit is contained in:
parent
699fc5b191
commit
1a554be3b6
|
@ -622,9 +622,11 @@ ReprocessLoop:
|
|||
(PN = dyn_cast<PHINode>(I++)); )
|
||||
if (Value *V = SimplifyInstruction(PN, DL, nullptr, DT, AC)) {
|
||||
if (SE) SE->forgetValue(PN);
|
||||
if (!PreserveLCSSA || LI->replacementPreservesLCSSAForm(PN, V)) {
|
||||
PN->replaceAllUsesWith(V);
|
||||
PN->eraseFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
// If this loop has multiple exits and the exits all go to the same
|
||||
// block, attempt to merge the exits. This helps several passes, such
|
||||
|
|
|
@ -151,3 +151,40 @@ L1_latch:
|
|||
exit:
|
||||
ret i8 0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @foo5
|
||||
define void @foo5() {
|
||||
entry:
|
||||
br label %outer
|
||||
|
||||
outer:
|
||||
br label %inner1
|
||||
|
||||
; CHECK: inner1:
|
||||
; CHECK-NOT: br i1 true
|
||||
; CHECK: br label %inner2_indirect_exit
|
||||
inner1:
|
||||
br i1 true, label %inner2_indirect_exit.preheader, label %inner1
|
||||
|
||||
inner2_indirect_exit.preheader:
|
||||
br label %inner2_indirect_exit
|
||||
|
||||
inner2_indirect_exit:
|
||||
%a = phi i32 [ %b, %inner2_latch ], [ undef, %inner2_indirect_exit.preheader ]
|
||||
indirectbr i8* undef, [label %inner2_latch, label %inner3, label %outer_latch]
|
||||
|
||||
inner2_latch:
|
||||
%b = load i32, i32* undef, align 8
|
||||
br label %inner2_indirect_exit
|
||||
|
||||
inner3:
|
||||
%a.lcssa = phi i32 [ %a.lcssa, %inner3 ], [ %a, %inner2_indirect_exit ]
|
||||
br i1 true, label %outer_latch.loopexit, label %inner3
|
||||
|
||||
outer_latch.loopexit:
|
||||
%a.lcssa.lcssa = phi i32 [ %a.lcssa, %inner3 ]
|
||||
br label %outer_latch
|
||||
|
||||
outer_latch:
|
||||
br label %outer
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue