]> granicus.if.org Git - llvm/commitdiff
Temporarily disable term folding in LoopSimplifyCFG, add tests
authorMax Kazantsev <max.kazantsev@azul.com>
Fri, 28 Dec 2018 06:22:39 +0000 (06:22 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Fri, 28 Dec 2018 06:22:39 +0000 (06:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350117 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopSimplifyCFG.cpp
test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll

index 1ad2499bbba1648e100076b2ac5f235e2a990cf8..4517b9b8f06ddb4d062ca64ffc922601770d8c45 100644 (file)
@@ -42,7 +42,7 @@ using namespace llvm;
 #define DEBUG_TYPE "loop-simplifycfg"
 
 static cl::opt<bool> EnableTermFolding("enable-loop-simplifycfg-term-folding",
-                                       cl::init(true));
+                                       cl::init(false));
 
 STATISTIC(NumTerminatorsFolded,
           "Number of terminators folded to unconditional branches");
index 919c10c39ec5158ed15b9ea5cc9bb14216b88813..db5f0f1f3f2ef77a9d8dd0cce74ca4e0ef857380 100644 (file)
@@ -1,4 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; XFAIL: *
+; Tests complex_dead_subloop_branch and complex_dead_subloop_switch fail an
+; assertion, therefore the CFG simplification is temporarily disabled.
 ; REQUIRES: asserts
 ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
 ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(simplify-cfg)' -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
@@ -2507,3 +2510,59 @@ loop_1_backedge:
 exit:
   ret i32 %i
 }
+
+define i32 @complex_dead_subloop_branch(i1 %cond1, i1 %cond2, i1 %cond3) {
+entry:
+  br label %loop
+
+loop:
+  br i1 true, label %latch, label %subloop
+
+subloop:
+  br i1 %cond1, label %x, label %y
+
+x:
+  br label %subloop_latch
+
+y:
+  br label %subloop_latch
+
+subloop_latch:
+  %dead_phi = phi i32 [ 1, %x ], [ 2, %y ]
+  br i1 %cond2, label %latch, label %subloop
+
+latch:
+  %result = phi i32 [ 0, %loop ], [ %dead_phi, %subloop_latch ]
+  br i1 %cond3, label %loop, label %exit
+
+exit:
+  ret i32 %result
+}
+
+define i32 @complex_dead_subloop_switch(i1 %cond1, i1 %cond2, i1 %cond3) {
+entry:
+  br label %loop
+
+loop:
+  switch i32 1, label %latch [ i32 0, label %subloop ]
+
+subloop:
+  br i1 %cond1, label %x, label %y
+
+x:
+  br label %subloop_latch
+
+y:
+  br label %subloop_latch
+
+subloop_latch:
+  %dead_phi = phi i32 [ 1, %x ], [ 2, %y ]
+  br i1 %cond2, label %latch, label %subloop
+
+latch:
+  %result = phi i32 [ 0, %loop ], [ %dead_phi, %subloop_latch ]
+  br i1 %cond3, label %loop, label %exit
+
+exit:
+  ret i32 %result
+}