@@ -13687,9 +13687,17 @@ mips_output_division (const char *division, rtx *operands)
}
else
{
- output_asm_insn ("%(bne\t%2,%.,1f", operands);
- output_asm_insn (s, operands);
- s = "break\t7%)\n1:";
+ if (flag_delayed_branch)
+ {
+ output_asm_insn ("%(bne\t%2,%.,1f", operands);
+ output_asm_insn (s, operands);
+ s = "break\t7%)\n1:";
+ }
+ else
+ {
+ output_asm_insn (s, operands);
+ s = "bne\t%2,%.,1f\n\tnop\n\tbreak\t7\n1:";
+ }
}
}
return s;
2015-12-15 Steve Ellcey <sellcey@imgtec.com>
PR target/65604
* gcc.target/mips/div-delay.c: New test.
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=mips1 -fno-delayed-branch" } */
+/* { dg-final { scan-assembler "\tbne\t.*\tnop" } } */
+
+/* Ensure that mips1 does not put anything in the delay slot of the bne
+ instruction when checking for divide by zero. mips2+ systems use teq
+ instead of bne and teq has no delay slot. */
+
+NOCOMPRESSION int
+foo (int a, int b)
+{
+ return a / b;
+}