[llvm] [SelectionDAG]: Deduce KnownNeverZero from SMIN and SMAX (PR #85722)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 10:53:56 PDT 2024


================
@@ -305,21 +360,77 @@ define i32 @smax_known_nonzero(i32 %xx, i32 %yy) {
   ret i32 %r
 }
 
-define i32 @smax_maybe_zero(i32 %x, i32 %y) {
-; CHECK-LABEL: smax_maybe_zero:
+define i32 @smax_known_zero_2(i32 %x, i32 %y) {
+; CHECK-LABEL: smax_known_zero_2:
 ; CHECK:       # %bb.0:
 ; CHECK-NEXT:    cmpl $55, %edi
 ; CHECK-NEXT:    movl $54, %eax
 ; CHECK-NEXT:    cmovgel %edi, %eax
-; CHECK-NEXT:    bsfl %eax, %ecx
-; CHECK-NEXT:    movl $32, %eax
-; CHECK-NEXT:    cmovnel %ecx, %eax
+; CHECK-NEXT:    rep bsfl %eax, %eax
 ; CHECK-NEXT:    retq
   %z = call i32 @llvm.smax.i32(i32 %x, i32 54)
   %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
   ret i32 %r
 }
 
+define <4 x i32> @smax_known_zero_vec(<4 x i32> %x, <4 x i32> %y) {
----------------
AtariDreams wrote:

Perhaps because the instructions generated for vectors aren't using known bits?

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


More information about the llvm-commits mailing list