https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65604
Bug ID: 65604 Summary: MIPS -fno-delayed-branch generates incorrect code with -mcheck-zero-division Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: azonenberg at drawersteak dot com When compiling code that performs integer division on MIPS with -fno-delayed-branch and -mcheck-zero-division enabled, the generated code still uses delay slots. Example disassembly: 400002e8: 14400002 bnez v0,400002f4 <main+0x124> 400002ec: 0062001a div zero,v1,v0 400002f0: 0007000d break 0x7 400002f4: 00001810 mfhi v1 Expected result: Code generated with -fno-delayed-branch will run correctly on a MIPS-like processor that does not have delay slots Actual result: The divide is never executed on processors without delay slots since the branch jumps. I first noticed the issue on mips-elf-gcc 4.9.2 and have not yet tested to see what other version(s) it is present in.