[PATCH] D147897: [ValueTracking] Use maximum shift count in `shl` when determining if `shl` can be zero.

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 14 10:12:59 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2688
+          computeKnownBits(I->getOperand(1), DemandedElts, Depth, Q);
+      if (!Known.One.shl(KnownCnt.getMaxValue()).isZero())
+        return true;
----------------
goldstein.w.n wrote:
> nikic wrote:
> > nikic wrote:
> > > Isn't this going to assert if the max value is wider than the bit width?
> > Should probably just use `KnownBits::shl()` here.
> > Should probably just use `KnownBits::shl()` here.
> 
> Will do, does using `KnownBits::shl` fix the issue of failing the assert if max value is too wide, or do I need to add a check for that? Adding a few tests for that case and not seeing any assertions.
> Should probably just use `KnownBits::shl()` here.

Using `KnownBits::shl(Known, KnownCnt).isNonZero()` causes regressions. How about just adding a checking `KnownCnt.getMaxValue().ult(Known.getBitWidth())`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147897



More information about the llvm-commits mailing list