Fixed issue with microMIPS long branch.
[oota-llvm.git] / lib / Target / Mips / MipsLongBranch.cpp
index ea8cc802835e462e8bc6b845d34afb3c1bdff5a4..2efe57847add8f8db348b9b503247c58cf40aae5 100644 (file)
@@ -437,8 +437,10 @@ bool MipsLongBranch::runOnMachineFunction(MachineFunction &F) {
       if (!I->Br || I->HasLongBranch)
         continue;
 
+      int ShVal = TM.getSubtarget<MipsSubtarget>().inMicroMipsMode() ? 2 : 4;
+
       // Check if offset fits into 16-bit immediate field of branches.
-      if (!ForceLongBranch && isInt<16>(computeOffset(I->Br) / 4))
+      if (!ForceLongBranch && isInt<16>(computeOffset(I->Br) / ShVal))
         continue;
 
       I->HasLongBranch = true;