From 9c837b7d0e2e2dffae804f3df49c4aeefe4743c0 Mon Sep 17 00:00:00 2001 From: Zhongyunde Date: Fri, 4 Aug 2023 09:06:12 +0800 Subject: [PATCH] [ValueTracking] Improve the coverage of isKnownToBeAPowerOfTwo for vscale 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 --- llvm/lib/Analysis/ValueTracking.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index e335d7c181995..f8aa72605a7c2 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -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);