On AMD GPUs we have source modifiers and output modifiers, which are bits
you can set on instructions to perform some simple no cost operations
on either the operands or the result of an instruction (floating point
The source modifiers are FABS and FNEG and are applied to the operands
before an instruction is executed.
The output modifiers are CLAMP (clamp result between 0.0f and 1.0f)
and OMOD (multiply the result by 0.5f, 2.0f, or 4.0f). These are
applied to the result of an instruction after it is executed.
For the R600 backend, I'm using the MachineOperand TargetFlags to
keep track of the modifiers, but I've noticed when I use them on
operands to COPY instructions they are not propagated when registers
are coalesced. Is this a bug, or should I not be using TargetFlags for
storing this kind of information?