Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -231,7 +231,8 @@ // Eliminate blocks that contain only PHI nodes and an // unconditional branch. - EverMadeChange |= EliminateMostlyEmptyBlocks(F); + if (!DisableBranchOpts) + EverMadeChange |= EliminateMostlyEmptyBlocks(F); // llvm.dbg.value is far away from the value then iSel may not be able // handle it properly. iSel will drop llvm.dbg.value if it can not Index: test/Transforms/CodeGenPrepare/disable-branch-opts.ll =================================================================== --- /dev/null +++ test/Transforms/CodeGenPrepare/disable-branch-opts.ll @@ -0,0 +1,20 @@ +; RUN: opt < %s -S -codegenprepare -disable-cgp-branch-opts | FileCheck %s + +define void @foo(i32 %x, float* %output) { +; CHECK-LABEL: @foo( + %1 = icmp eq i32 %x, 1 + br i1 %1, label %then, label %else + +then: +; CHECK: then: + br label %merge + +else: +; CHECK: else: + br label %merge + +merge: +; CHECK: merge: + store float 2.0, float* %output + ret void +}