Open
Description
In this playground the ternary_and
example (roughly x < 3 ? 0 : x & 2
) causes two redundant cmovx to be emitted. (They're redundant, as high bits of eax are already zeroed). The real world case I initially noticed this behaviour was using sub nuw
instead of and
. Here also high bits of eax should be zeroed (although opt
turns this sub nuw
into add
, losing nuw
annotation). This particular case is especially bad, since it uses movzx
within same register (which I've read is not eligible to mov-elimination).
Perhaps related: #56498
edit: Removed the cast
example and added zeroext
attribute to arguments.