[llvm] 461ded4 - [ValueTracking] Add logic for `isKnownNonZero(ssub.sat X, Y)`

Noah Goldstein via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 30 08:07:16 PDT 2023


Author: Noah Goldstein
Date: 2023-04-30T10:06:45-05:00
New Revision: 461ded4631074c7636edd5985ce15b3748f6a9e2

URL: https://github.com/llvm/llvm-project/commit/461ded4631074c7636edd5985ce15b3748f6a9e2
DIFF: https://github.com/llvm/llvm-project/commit/461ded4631074c7636edd5985ce15b3748f6a9e2.diff

LOG: [ValueTracking] Add logic for `isKnownNonZero(ssub.sat X, Y)`

The logic here is the same for normal `(sub X, Y)`, so just reused
`isNonZeroSub`.

Alive2 Link:
    https://alive2.llvm.org/ce/z/9kSkMv

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D149412

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 0439f4e5f0d2..052b1aed47e9 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2929,6 +2929,9 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
         if (isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q))
           return true;
         break;
+      case Intrinsic::ssub_sat:
+        return isNonZeroSub(DemandedElts, Depth, Q, BitWidth,
+                            II->getArgOperand(0), II->getArgOperand(1));
       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 61cbe13db027..ca158c2ed91a 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -855,12 +855,7 @@ define i1 @ushl_nonzero_fail_x_maybe_z(i8 %xx, i8 %y, i8 %ind) {
 
 define i1 @ssub_sat_nonzero(i8 %xx, i8 %yy, i8 %ind) {
 ; CHECK-LABEL: @ssub_sat_nonzero(
-; CHECK-NEXT:    [[XA:%.*]] = and i8 [[XX:%.*]], -65
-; CHECK-NEXT:    [[YO:%.*]] = or i8 [[YY:%.*]], 64
-; CHECK-NEXT:    [[X:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[XA]], i8 [[YO]])
-; 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
 ;
   %xa = and i8 %xx, 191
   %yo = or i8 %yy, 64


        


More information about the llvm-commits mailing list