[llvm] [X86] Limit the result of XOR8rr_NOREX unused (PR #218640)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 05:50:49 PDT 2026
================
@@ -884,6 +884,18 @@ def xor_flag_nocf : PatFrag<(ops node:$lhs, node:$rhs),
return hasNoCarryFlagUses(SDValue(N, 1));
}]>;
+// Only matches when the data (non-flags) result of the xor is unused, i.e. the
+// __builtin_parity idiom where only EFLAGS are consumed. This guards the 64-bit
+// h-register XOR8rr_NOREX pattern: its GR8_NOREX result may be allocated to a
+// high-byte register (AH/BH/CH/DH), which cannot be encoded in a REX-prefixed
+// instruction. If the result value escaped (e.g. got zero/sign-extended into an
+// R8-R15 register) the encoder would fail, so restrict the trick to the case
+// where the value result has no uses at all.
----------------
RKSimon wrote:
Would most of this description be better as part of the comment for the fold in X86InstrCompiler.td?
https://github.com/llvm/llvm-project/pull/218640
More information about the llvm-commits
mailing list