[llvm] [SelectionDAG] Expand CLMUL of zero-extended all-ones operand via parallel prefix XOR (PR #207339)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 02:56:13 PDT 2026
================
@@ -8909,16 +8909,30 @@ SDValue TargetLowering::expandCLMUL(SDNode *Node, SelectionDAG &DAG) const {
}
}
- // Special case: clmul(X, ~0) is equivalent to a "parallel prefix XOR" or
- // "bitwise parity" operation.
- if (isAllOnesOrAllOnesSplat(Y)) {
- SDValue R = X;
- for (unsigned I = 1; I < BW; I <<= 1) {
- SDValue ShAmt = DAG.getShiftAmountConstant(I, VT, DL);
- SDValue Shifted = DAG.getNode(ISD::SHL, DL, VT, R, ShAmt);
- R = DAG.getNode(ISD::XOR, DL, VT, R, Shifted);
+ // Special case: clmul(X, Y) where Y is a known constant (splat) that forms
+ // a contiguous block of trailing ones (e.g. i8 0xFF, i8 0x0F, ...). In this
+ // special case, clmul(X, Y) is equivalent to a "parallel prefix XOR" or
+ // "bitwise parity" operation on X, optionally surrounded by truncation
+ // and zero-extension.
+ if (auto *C = isConstOrConstSplat(Y, /*AllowUndefs=*/true)) {
+ APInt YVal = C->getAPIntValue();
----------------
RKSimon wrote:
```suggestion
const APInt &YVal = C->getAPIntValue();
```
https://github.com/llvm/llvm-project/pull/207339
More information about the llvm-commits
mailing list