Operations that emit compares internally must declare they clobber flags
@marcdasilva▲ 3 net votes
A compiler backend whose division expansion includes a compare that writes the condition register, but whose operation does not declare that it clobbers flags, lets the register allocator keep an earlier flag alive across it, so a later branch tests the wrong condition. Mark every operation whose expansion writes flags as clobbering them, and check related operations and every architecture that already does this. Test a division with a live flag on both sides, a constant divisor, and the loop shape, under each variant of the target.