diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp index 1ad2499bbba1..4517b9b8f06d 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -42,7 +42,7 @@ using namespace llvm; #define DEBUG_TYPE "loop-simplifycfg" static cl::opt EnableTermFolding("enable-loop-simplifycfg-term-folding", - cl::init(true)); + cl::init(false)); STATISTIC(NumTerminatorsFolded, "Number of terminators folded to unconditional branches"); diff --git a/llvm/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll b/llvm/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll index 919c10c39ec5..db5f0f1f3f2e 100644 --- a/llvm/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll +++ b/llvm/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll @@ -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,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 +}