2 ms·
Yes. In general, compilers only test emit flag testing instructions after instructions that are explicitly defined as having flag-modifying semantics. (This is
by woodruffw 4y ago
Yes. In general, compilers only test emit flag testing instructions after instructions that are explicitly defined as having flag-modifying semantics.
(This is a common feature of ISAs, and makes sense in terms of component reuse: it allows you to cheaply reuse the ALU, for example, without needing extra wires/control signals telling it not to update the flag state.)
- Someone 4y ago> compilers only emit flag testing instructions after instructions that are explicitly defined as having flag-modifying semantics. I think compiler writers sometimes also have to know that instructions do not modify the flags. Such instructions can be inserted between flag-setting ones and the test of that flag.
- woodruffw 4y agoYes, good point! It would have been more accurate for me to say “the compiler should always have a model of the flags during lowering.”