diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 482316c6111f9..c9d4641fd6ddd 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -6634,7 +6634,8 @@ bool SimplifyCFGOpt::simplifyOnceImpl(BasicBlock *BB) { Changed |= EliminateDuplicatePHINodes(BB); // Check for and remove branches that will always cause undefined behavior. - Changed |= removeUndefIntroducingPredecessor(BB, DTU); + if (removeUndefIntroducingPredecessor(BB, DTU)) + return requestResimplify(); // Merge basic blocks into their predecessor if there is only one distinct // pred, and if there is only one distinct successor of the predecessor, and diff --git a/llvm/test/Transforms/SimplifyCFG/tautological-conditional-branch.ll b/llvm/test/Transforms/SimplifyCFG/tautological-conditional-branch.ll index 31ab0fa60dbe8..912598197080e 100644 --- a/llvm/test/Transforms/SimplifyCFG/tautological-conditional-branch.ll +++ b/llvm/test/Transforms/SimplifyCFG/tautological-conditional-branch.ll @@ -15,8 +15,7 @@ define void @eggs(i1 %arg, i1 %arg16, %0* %arg17, %0* %arg18, %0* %arg19) { ; CHECK: bb21: ; CHECK-NEXT: [[I:%.*]] = icmp eq %0* [[ARG17:%.*]], null ; CHECK-NEXT: call void @hoge() -; CHECK-NEXT: [[I26:%.*]] = select i1 [[ARG16:%.*]], %0* null, %0* [[ARG19:%.*]] -; CHECK-NEXT: [[I27:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[I26]], i64 0, i32 0 +; CHECK-NEXT: [[I27:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[ARG19:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[I28:%.*]] = load %1*, %1** [[I27]], align 8 ; CHECK-NEXT: call void @pluto.1(%1* [[I28]]) ; CHECK-NEXT: call void @pluto()