[PATCH] D156881: [InstSimplify] Check the NonZero for power of two value

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 15:09:14 PDT 2023


goldstein.w.n accepted this revision.
goldstein.w.n added a comment.
This revision is now accepted and ready to land.

LGTM.



================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2022
+  if (Q.CxtI &&
+      (match(V, m_VScale()) || match(V, m_Shl(m_VScale(), m_Value())))) {
     const Function *F = Q.CxtI->getFunction();
----------------
Allen wrote:
> goldstein.w.n wrote:
> > What is this change for? Is this part of the bugfix?
> Yes.  This is similar to the following logic in line 2045. 
> ```
>   // A shift left or a logical shift right of a power of two is a power of two
>   // or zero.
>   if (OrZero && (match(V, m_Shl(m_Value(X), m_Value())) ||
>                  match(V, m_LShr(m_Value(X), m_Value()))))
>     return isKnownToBeAPowerOfTwo(X, /*OrZero*/ true, Depth, Q);
> ```
> 
> This is try to match following code, because we can assume the vscale always bigger than 1, and it is a power of 2 if it has the attribute of vscale_range
> ```
> %vscale = call i64 @llvm.vscale.i64()
>   %shift = shl nuw nsw i64 %vscale, 11
> ```
> 
> 
> 
But is it related to making the existing codes correct or just improving the coverage? I don't see how its related to the bug. If its not related to the bug, imo it should be split to a seperate patch.


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

https://reviews.llvm.org/D156881



More information about the llvm-commits mailing list