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

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 29 11:42:20 PDT 2023


goldstein.w.n updated this revision to Diff 518207.
goldstein.w.n added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149412/new/

https://reviews.llvm.org/D149412

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
@@ -855,12 +855,7 @@
 
 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
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2929,6 +2929,10 @@
         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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149412.518207.patch
Type: text/x-patch
Size: 1438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230429/047955fc/attachment.bin>


More information about the llvm-commits mailing list