Index: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -418,7 +418,7 @@ LI.removeBlock(BB); } - DetatchDeadBlocks(DeadLoopBlocks, &DTUpdates); + DetatchDeadBlocks(DeadLoopBlocks, &DTUpdates, /*KeepOneInputPHIs*/true); DTU.applyUpdates(DTUpdates); DTUpdates.clear(); for (auto *BB : DeadLoopBlocks) Index: llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll =================================================================== --- llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll +++ llvm/trunk/test/Transforms/LoopSimplifyCFG/lcssa.ll @@ -1,6 +1,4 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; XFAIL: * -; REQUIRES: asserts ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa < %s | FileCheck %s ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require,loop(simplify-cfg)' -verify-loop-info -verify-dom-info -verify-loop-lcssa < %s | FileCheck %s ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg -enable-mssa-loop-dependency=true -verify-memoryssa -verify-loop-info -verify-dom-info -verify-loop-lcssa < %s | FileCheck %s @@ -93,8 +91,31 @@ } define void @bar() { - -; CHECK-LABEL: @bar +; CHECK-LABEL: @bar( +; CHECK-NEXT: bb: +; CHECK-NEXT: switch i32 0, label [[BB_SPLIT:%.*]] [ +; CHECK-NEXT: i32 1, label [[BB10:%.*]] +; CHECK-NEXT: ] +; CHECK: bb-split: +; CHECK-NEXT: br label [[BB1:%.*]] +; CHECK: bb1: +; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ [[TMP7:%.*]], [[BB6:%.*]] ], [ undef, [[BB_SPLIT]] ] +; CHECK-NEXT: switch i32 undef, label [[BB5:%.*]] [ +; CHECK-NEXT: i32 0, label [[BB6]] +; CHECK-NEXT: i32 1, label [[BB8:%.*]] +; CHECK-NEXT: ] +; CHECK: bb5: +; CHECK-NEXT: ret void +; CHECK: bb6: +; CHECK-NEXT: [[TMP7]] = add i32 undef, 123 +; CHECK-NEXT: br label [[BB1]] +; CHECK: bb8: +; CHECK-NEXT: [[TMP9:%.*]] = phi i32 [ [[TMP]], [[BB1]] ] +; CHECK-NEXT: [[USE:%.*]] = add i32 [[TMP9]], 1 +; CHECK-NEXT: ret void +; CHECK: bb10: +; CHECK-NEXT: ret void +; bb: br label %bb1 @@ -105,8 +126,8 @@ bb2: ; preds = %bb1 switch i32 undef, label %bb10 [ - i32 0, label %bb3 - i32 1, label %bb8 + i32 0, label %bb3 + i32 1, label %bb8 ] bb3: ; preds = %bb2 @@ -114,8 +135,8 @@ bb4: ; preds = %bb1 switch i32 undef, label %bb5 [ - i32 0, label %bb6 - i32 1, label %bb8 + i32 0, label %bb6 + i32 1, label %bb8 ] bb5: ; preds = %bb4