Skip to content

Commit

Permalink
[ValueTracking] Improve the coverage of isKnownToBeAPowerOfTwo for vs…
Browse files Browse the repository at this point in the history
…cale

this PR tries to match the following pattern, seperate from D156881
     ```
     %vscale = call i64 @llvm.vscale.i64()
     %shift = shl nuw nsw i64 %vscale, 11
     ```
Now, we only check the shl recursively when the OrZero is true.

Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D157062
  • Loading branch information
vfdff committed Aug 4, 2023
1 parent 08dc847 commit 9c837b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/Analysis/ValueTracking.cpp
Expand Up @@ -2018,7 +2018,8 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
return true;
if (match(V, m_Power2()))
return true;
if (Q.CxtI && match(V, m_VScale())) {
if (Q.CxtI &&
(match(V, m_VScale()) || match(V, m_Shl(m_VScale(), m_Value())))) {
const Function *F = Q.CxtI->getFunction();
// The vscale_range indicates vscale is a power-of-two.
return F->hasFnAttribute(Attribute::VScaleRange);
Expand Down

0 comments on commit 9c837b7

Please sign in to comment.