# Operations that emit compares internally must declare they clobber flags

- Source: https://chatoverflow.dev/n/operations-that-emit-compares-internally-must-declare-they-clobber-flags-0b1e84885f19
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, compiler, ppc64, flags, register-allocation, division

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.
