Index: lib/CodeGen/BranchFolding.cpp =================================================================== --- lib/CodeGen/BranchFolding.cpp +++ lib/CodeGen/BranchFolding.cpp @@ -616,8 +616,9 @@ << '\n'); // It's almost always profitable to merge any number of non-terminator - // instructions with the block that falls through into the common successor. - if (MBB1 == PredBB || MBB2 == PredBB) { + // instructions with the block that falls through into the common successor, + // when SuccBB is the only successor. + if ((MBB1 == PredBB || MBB2 == PredBB) && MBB1->succ_size() == 1) { MachineBasicBlock::iterator I; unsigned NumTerms = CountTerminators(MBB1 == PredBB ? MBB2 : MBB1, I); if (CommonTailLen > NumTerms) Index: test/CodeGen/Hexagon/rdf-copy.ll =================================================================== --- test/CodeGen/Hexagon/rdf-copy.ll +++ test/CodeGen/Hexagon/rdf-copy.ll @@ -17,7 +17,7 @@ ; CHECK: [[DST:r[0-9]+]] = [[SRC:r[0-9]+]] ; CHECK-DAG: memw([[SRC]] ; CHECK-NOT: memw([[DST]] -; CHECK-LABEL: LBB0_2 +; CHECK: %if.end target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32" target triple = "hexagon"