[llvm] 167ecda - [ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 30 08:07:18 PDT 2023
Author: Noah Goldstein
Date: 2023-04-30T10:06:46-05:00
New Revision: 167ecdaa2cc34e942b99c567c0b076923ea220c3
URL: https://github.com/llvm/llvm-project/commit/167ecdaa2cc34e942b99c567c0b076923ea220c3
DIFF: https://github.com/llvm/llvm-project/commit/167ecdaa2cc34e942b99c567c0b076923ea220c3.diff
LOG: [ValueTracking] Add logic for `isKnownNonZero(sadd.sat X, Y)`
The logic here is the same for `add` so reuse the existing helper
`isNonZeroAdd`
Alive2 Link:
https://alive2.llvm.org/ce/z/mhKvC5
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149414
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 052b1aed47e9..72b89a2eac78 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2932,6 +2932,10 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
case Intrinsic::ssub_sat:
return isNonZeroSub(DemandedElts, Depth, Q, BitWidth,
II->getArgOperand(0), II->getArgOperand(1));
+ case Intrinsic::sadd_sat:
+ return isNonZeroAdd(DemandedElts, Depth, Q, BitWidth,
+ II->getArgOperand(0), II->getArgOperand(1),
+ /*NSW*/ true);
case Intrinsic::uadd_sat:
if (isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q) ||
isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q))
diff --git a/llvm/test/Analysis/ValueTracking/known-non-zero.ll b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
index ca158c2ed91a..05723316adfa 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -924,10 +924,7 @@ define i1 @sadd_sat_nonzero(i8 %xx, i8 %yy, i8 %ind) {
; CHECK-NEXT: [[Y_POS:%.*]] = icmp sge i8 [[YY:%.*]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[X_STRICT_POS]])
; CHECK-NEXT: call void @llvm.assume(i1 [[Y_POS]])
-; CHECK-NEXT: [[X:%.*]] = call i8 @llvm.sadd.sat.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_strict_pos = icmp sgt i8 %xx, 0
%y_pos = icmp sge i8 %yy, 0
More information about the llvm-commits
mailing list