[llvm] [X86] combineSETCC - drop unnecessary shift amount bounds check for larger-than-legal ICMP_ZERO(AND(X,SHL(1,IDX))) folds (PR #182021)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 19 01:42:44 PST 2026


================
@@ -341,43 +341,20 @@ define i1 @scalar_i64_signbit_eq(i64 %x, i64 %y) nounwind {
 }
 
 define i1 @scalar_i64_lowestbit_eq(i64 %x, i64 %y) nounwind {
-; X86-BMI1-LABEL: scalar_i64_lowestbit_eq:
-; X86-BMI1:       # %bb.0:
-; X86-BMI1-NEXT:    pushl %esi
-; X86-BMI1-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx
-; X86-BMI1-NEXT:    movl $1, %eax
-; X86-BMI1-NEXT:    xorl %esi, %esi
-; X86-BMI1-NEXT:    xorl %edx, %edx
-; X86-BMI1-NEXT:    shldl %cl, %eax, %edx
-; X86-BMI1-NEXT:    shll %cl, %eax
-; X86-BMI1-NEXT:    testb $32, %cl
-; X86-BMI1-NEXT:    cmovnel %eax, %edx
-; X86-BMI1-NEXT:    cmovnel %esi, %eax
-; X86-BMI1-NEXT:    andl {{[0-9]+}}(%esp), %edx
-; X86-BMI1-NEXT:    andl {{[0-9]+}}(%esp), %eax
-; X86-BMI1-NEXT:    orl %edx, %eax
-; X86-BMI1-NEXT:    sete %al
-; X86-BMI1-NEXT:    popl %esi
-; X86-BMI1-NEXT:    retl
-;
-; X86-BMI2-LABEL: scalar_i64_lowestbit_eq:
-; X86-BMI2:       # %bb.0:
-; X86-BMI2-NEXT:    pushl %esi
-; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx
-; X86-BMI2-NEXT:    movl $1, %edx
-; X86-BMI2-NEXT:    xorl %esi, %esi
-; X86-BMI2-NEXT:    xorl %eax, %eax
-; X86-BMI2-NEXT:    shldl %cl, %edx, %eax
-; X86-BMI2-NEXT:    shlxl %ecx, %edx, %edx
-; X86-BMI2-NEXT:    testb $32, %cl
-; X86-BMI2-NEXT:    cmovnel %edx, %eax
-; X86-BMI2-NEXT:    cmovnel %esi, %edx
-; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %eax
-; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %edx
-; X86-BMI2-NEXT:    orl %eax, %edx
-; X86-BMI2-NEXT:    sete %al
-; X86-BMI2-NEXT:    popl %esi
-; X86-BMI2-NEXT:    retl
+; X86-LABEL: scalar_i64_lowestbit_eq:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    testb $32, %al
+; X86-NEXT:    je .LBB10_1
----------------
RKSimon wrote:

I meant in narrowBitOpRMW we directly use the shift amount to alter the pointer offset, so we want to be very careful - here we leave it to generic shift expansion code to handle the bounds check, although in this particular case the aligned shift means it all simplifies away.

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


More information about the llvm-commits mailing list