[PATCH] D149416: [ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 27 23:21:20 PDT 2023
goldstein.w.n created this revision.
goldstein.w.n added reviewers: StephenFan, nikic, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
`(umin X, Y) != 0` -> `X != 0 && Y != 0`
Alive2 Link:
https://alive2.llvm.org/ce/z/AQh67i
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149416
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-zero.ll
Index: llvm/test/Analysis/ValueTracking/known-non-zero.ll
===================================================================
--- llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -919,10 +919,7 @@
; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]])
; CHECK-NEXT: [[Y_NZ:%.*]] = icmp ne i8 [[YY:%.*]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[Y_NZ]])
-; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.umin.i8(i8 [[XX]], i8 [[YY]])
-; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]]
-; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 false
;
%x_nz = icmp ne i8 %xx, 0
call void @llvm.assume(i1 %x_nz)
@@ -957,10 +954,7 @@
; CHECK-NEXT: call void @llvm.assume(i1 [[X_NZ]])
; CHECK-NEXT: [[Y_NZ:%.*]] = icmp ne i8 [[YY:%.*]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[Y_NZ]])
-; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.umin.i8(i8 [[XX]], i8 [[YY]])
-; CHECK-NEXT: [[Z:%.*]] = or i8 [[X]], [[IND:%.*]]
-; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Z]], 0
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 false
;
%x_nz = icmp ne i8 %xx, 0
call void @llvm.assume(i1 %x_nz)
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2926,6 +2926,9 @@
isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q))
return true;
break;
+ case Intrinsic::umin:
+ return isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q) &&
+ isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q);
case Intrinsic::cttz:
return computeKnownBits(II->getArgOperand(0), DemandedElts, Depth, Q)
.Zero[0];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149416.517800.patch
Type: text/x-patch
Size: 1874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230428/e3478c87/attachment.bin>
More information about the llvm-commits
mailing list