[PATCH] D149372: [ValueTracking] Add logic for `fshl/fshr(A, B, C) != 0` if `A == B && A ! = 0`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 23:58:00 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cd1b67491df: [ValueTracking] Add logic for `fshl/fshr(A, B, C) != 0` if `A == B && A ! = 0` (authored by goldstein.w.n).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149372

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
@@ -532,10 +532,7 @@
 ; CHECK-LABEL: @fshr_non_zero(
 ; CHECK-NEXT:    [[PRED0:%.*]] = icmp ne i8 [[X:%.*]], 0
 ; CHECK-NEXT:    call void @llvm.assume(i1 [[PRED0]])
-; CHECK-NEXT:    [[V:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X]], i8 [[X]], i8 [[Y:%.*]])
-; CHECK-NEXT:    [[OR:%.*]] = or i8 [[V]], [[Z:%.*]]
-; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[OR]], 0
-; CHECK-NEXT:    ret i1 [[R]]
+; CHECK-NEXT:    ret i1 false
 ;
   %pred0 = icmp ne i8 %x, 0
   call void @llvm.assume(i1 %pred0)
@@ -570,10 +567,7 @@
 ; CHECK-LABEL: @fshl_non_zero(
 ; CHECK-NEXT:    [[PRED0:%.*]] = icmp ne i8 [[X:%.*]], 0
 ; CHECK-NEXT:    call void @llvm.assume(i1 [[PRED0]])
-; CHECK-NEXT:    [[V:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X]], i8 [[X]], i8 [[Y:%.*]])
-; CHECK-NEXT:    [[OR:%.*]] = or i8 [[V]], [[Z:%.*]]
-; CHECK-NEXT:    [[R:%.*]] = icmp eq i8 [[OR]], 0
-; CHECK-NEXT:    ret i1 [[R]]
+; CHECK-NEXT:    ret i1 false
 ;
   %pred0 = icmp ne i8 %x, 0
   call void @llvm.assume(i1 %pred0)
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2894,6 +2894,12 @@
             isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q))
           return true;
         break;
+      case Intrinsic::fshr:
+      case Intrinsic::fshl:
+        // If Op0 == Op1, this is a rotate. rotate(x, y) != 0 iff x != 0.
+        if (II->getArgOperand(0) == II->getArgOperand(1))
+          return isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q);
+        break;
       case Intrinsic::vscale:
         return true;
       default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149372.517819.patch
Type: text/x-patch
Size: 1908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230428/3635abb8/attachment.bin>


More information about the llvm-commits mailing list