Index: lib/Target/Mips/MipsBranchExpansion.cpp =================================================================== --- lib/Target/Mips/MipsBranchExpansion.cpp +++ lib/Target/Mips/MipsBranchExpansion.cpp @@ -271,7 +271,8 @@ // Insert NewMBB and fix control flow. MachineBasicBlock *Tgt = getTargetMBB(*FirstBr); NewMBB->transferSuccessors(MBB); - NewMBB->removeSuccessor(Tgt, true); + if (Tgt != getTargetMBB(*LastBr)) + NewMBB->removeSuccessor(Tgt, true); MBB->addSuccessor(NewMBB); MBB->addSuccessor(Tgt); MFp->insert(std::next(MachineFunction::iterator(MBB)), NewMBB); Index: test/CodeGen/Mips/micromips-mtc-mfc.ll =================================================================== --- test/CodeGen/Mips/micromips-mtc-mfc.ll +++ test/CodeGen/Mips/micromips-mtc-mfc.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -mtriple=mips -mcpu=mips32r2 -mattr=+micromips \ +; RUN: llc -mtriple=mips -mcpu=mips32r2 -mattr=+micromips -verify-machineinstrs \ ; RUN: -show-mc-encoding < %s | FileCheck --check-prefix=MM2 %s -; RUN: llc -mtriple=mips -mcpu=mips32r6 -mattr=+micromips \ +; RUN: llc -mtriple=mips -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs \ ; RUN: -show-mc-encoding < %s | FileCheck --check-prefix=MM6 %s define double @foo(double %a, double %b) {