diff options
| author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2014-12-22 22:35:46 +0000 |
|---|---|---|
| committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2014-12-22 22:35:46 +0000 |
| commit | bad65c3b708accec8c6e85346dabc7967cb3d7ca (patch) | |
| tree | 859975d0c73e10979f445919d266492d4b42617d /llvm/test | |
| parent | a47ace59019721411307ab06eea5b7796cb3dd3e (diff) | |
| download | bcm5719-llvm-bad65c3b708accec8c6e85346dabc7967cb3d7ca.tar.gz bcm5719-llvm-bad65c3b708accec8c6e85346dabc7967cb3d7ca.zip | |
[LCSSA] Handle PHI insertion in disjoint loops
Take two disjoint Loops L1 and L2.
LoopSimplify fails to simplify some loops (e.g. when indirect branches
are involved). In such situations, it can happen that an exit for L1 is
the header of L2. Thus, when we create PHIs in one of such exits we are
also inserting PHIs in L2 header.
This could break LCSSA form for L2 because these inserted PHIs can also
have uses in L2 exits, which are never handled in the current
implementation. Provide a fix for this corner case and test that we
don't assert/crash on that.
Differential Revision: http://reviews.llvm.org/D6624
rdar://problem/19166231
llvm-svn: 224740
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/LCSSA/indirectbr.ll | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/llvm/test/Transforms/LCSSA/indirectbr.ll b/llvm/test/Transforms/LCSSA/indirectbr.ll index 96564486e82..345395bee01 100644 --- a/llvm/test/Transforms/LCSSA/indirectbr.ll +++ b/llvm/test/Transforms/LCSSA/indirectbr.ll @@ -1,11 +1,11 @@ -; RUN: opt < %s -lcssa -verify-loop-info -verify-dom-info -disable-output -; PR5437 +; RUN: opt < %s -loop-simplify -lcssa -verify-loop-info -verify-dom-info -S | FileCheck %s ; LCSSA should work correctly in the case of an indirectbr that exits ; the loop, and the loop has exits with predecessors not within the loop ; (and btw these edges are unsplittable due to the indirectbr). - -define i32 @js_Interpret() nounwind { +; PR5437 +define i32 @test0() nounwind { +; CHECK-LABEL: @test0 entry: br i1 undef, label %"4", label %"3" @@ -540,3 +540,35 @@ entry: "1862": ; preds = %"1836", %"692" unreachable } + +; An exit for Loop L1 may be the header of a disjoint Loop L2. Thus, when we +; create PHIs in one of such exits we are also inserting PHIs in L2 header. This +; could break LCSSA form for L2 because these inserted PHIs can also have uses +; in L2 exits. Test that we don't assert/crash on that. +define void @test1() { +; CHECK-LABEL: @test1 + br label %lab1 + +lab1: + %tmp21 = add i32 undef, 677038203 + br i1 undef, label %lab2, label %exit + +lab2: + indirectbr i8* undef, [label %lab1, label %lab3] + +lab3: +; CHECK: %tmp21.lcssa1 = phi i32 [ %tmp21.lcssa1, %lab4 ], [ %tmp21, %lab2 ] + %tmp12 = phi i32 [ %tmp21, %lab2 ], [ %tmp12, %lab4 ] + br i1 undef, label %lab5, label %lab4 + +lab4: + br label %lab3 + +lab5: +; CHECK: %tmp21.lcssa1.lcssa = phi i32 [ %tmp21.lcssa1, %lab3 ] + %tmp15 = add i32 %tmp12, undef + br label %exit + +exit: + ret void +} |

