Conditional Moves in the IR

Today we added conditional move instructions (CMOVs) to the intermediate representation (IR). They are closely related to GUARDs, but with two additional arguments that represent the two optional values the CMOV will pick from. MIN, MAX, ABS were previously modeled as separate and explicit instructions in the IR. Instead, these are now expressed through CMOV:

  • MIN(a, b) CMOV LE, a, b, a, b    
  • MAX(a, b) CMOV GE, a, b, a, b
  • ABS(a, b) n = NEG(a), CMOV GE, a, n, a, n

In the backend CMOVs are implemented using machine-level conditional moves, or in case of floating-point MIN/MAX we match the form CMOV x, a, b, c, d with (x == LE) and (a == c) and (b == d) and emit it as x86 MINSS instruction.