[llvm] e78c30a - [ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 30 08:07:21 PDT 2023
Author: Noah Goldstein
Date: 2023-04-30T10:06:46-05:00
New Revision: e78c30a10fe73c03843604a9d06ac55b87fda735
URL: https://github.com/llvm/llvm-project/commit/e78c30a10fe73c03843604a9d06ac55b87fda735
DIFF: https://github.com/llvm/llvm-project/commit/e78c30a10fe73c03843604a9d06ac55b87fda735.diff
LOG: [ValueTracking] Add logic for `isKnownNonZero(umin X, Y)`
`(umin X, Y) != 0` -> `X != 0 && Y != 0`
Alive2 Link:
https://alive2.llvm.org/ce/z/AQh67i
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149416
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-zero.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 75f5e40e993c..8551de669475 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2942,6 +2942,9 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
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];
diff --git a/llvm/test/Analysis/ValueTracking/known-non-zero.ll b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
index a01a9cd59197..5f45d30d65fb 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -994,10 +994,7 @@ define i1 @umin_nonzero(i8 %xx, i8 %yy, i8 %ind) {
; 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)
@@ -1032,10 +1029,7 @@ define i1 @smin_nonzero(i8 %xx, i8 %yy, i8 %ind) {
; 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)
More information about the llvm-commits
mailing list