[llvm] [SelectionDAG] Expand CLMUL of zero-extended all-ones operand via parallel prefix XOR (PR #207339)

Jan Schultke via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 3 23:50:33 PDT 2026


eisenwave wrote:

@8051Enthusiast I feel like you may be one the right track, but the solution seems like it becomes recursive then. I couldn't come up with anything better though.

Basically, you're trying to undo the last loop iteration by doing `xor CLMUL(X, ~Y & M)` where `M` is a mask with `bit_ceil(N)` bits.

So for example, if we had 20 mask bits, the loop would implicitly behave as if we had 32 mask bits, which means we then need to XOR with a 12-bit mask, shifted to the left by 20. But the 12-bit mask also involves the same issue: the loop would behave as if we had 16 bits, so we need to XOR a 4-bit mask from that.

Anyway, this all seems theoretically doable to me, but too ambitious for a single PR to be honest. I think I'll just limit it to work with masks that are powers of two.

https://github.com/llvm/llvm-project/pull/207339


More information about the llvm-commits mailing list