[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:24:54 PDT 2026
================
@@ -2022,6 +2022,49 @@ define i32 @clmul_i32_allones(i32 %x) nounwind {
ret i32 %r
}
+define i32 @clmul_i32_zext_allones(i16 %x) nounwind {
+; SCALAR-LABEL: clmul_i32_zext_allones:
+; SCALAR: # %bb.0:
+; SCALAR-NEXT: movzwl %di, %eax
+; SCALAR-NEXT: leal (%rax,%rax), %ecx
+; SCALAR-NEXT: xorl %eax, %ecx
+; SCALAR-NEXT: leal (,%rcx,4), %eax
+; SCALAR-NEXT: xorl %ecx, %eax
+; SCALAR-NEXT: movl %eax, %ecx
+; SCALAR-NEXT: shll $4, %ecx
+; SCALAR-NEXT: xorl %eax, %ecx
+; SCALAR-NEXT: movl %ecx, %eax
+; SCALAR-NEXT: shll $8, %eax
+; SCALAR-NEXT: xorl %ecx, %eax
----------------
eisenwave wrote:
I'm an idiot. I only ran `ninja llc` and ran the fuzzer tests with a stale clang binary, so yeah, nothing would be tripped.
It's definitely wrong to zero-extend from 16-bit to 32-bit here; this would always remove the upper 16 bits, and it's clear why that happens in `TargetLowering.cpp`.
https://github.com/llvm/llvm-project/pull/207339
More information about the llvm-commits
mailing list