[PATCH] D148404: [ValueTracking] Apply the isKnownNonZero techniques in `ashr`/`lshl` to `shl` and vice-versa

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 15 01:17:41 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2518
+                           const KnownBits &KnownVal) {
+  auto ShiftOp = [&](APInt Lhs, APInt Rhs) {
+    switch (I->getOpcode()) {
----------------
`const APInt &`


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2543
+
+  if(KnownVal.isUnknown())
+      return false;
----------------
clang-format


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2736
 
-    if (!Known.isUnknown()) {
-      KnownBits KnownCnt =
-          computeKnownBits(I->getOperand(1), DemandedElts, Depth, Q);
-
-      if (KnownCnt.getMaxValue().ult(Known.getBitWidth()) &&
-          !Known.One.shl(KnownCnt.getMaxValue()).isZero())
-        return true;
-    }
+    if (isNonZeroShift(I, DemandedElts, Depth, Q, Known))
+      return true;
----------------
This and below should directly return, because we don't want to fall through to the generic known bits logic anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148404



More information about the llvm-commits mailing list