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

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 14:45:41 PDT 2023


Allen marked an inline comment as done.
Allen added inline comments.


================
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();
----------------
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
```





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

https://reviews.llvm.org/D156881



More information about the llvm-commits mailing list