[llvm] 9c837b7 - [ValueTracking] Improve the coverage of isKnownToBeAPowerOfTwo for vscale
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 18:11:35 PDT 2023
Author: Zhongyunde
Date: 2023-08-04T09:06:34+08:00
New Revision: 9c837b7d0e2e2dffae804f3df49c4aeefe4743c0
URL: https://github.com/llvm/llvm-project/commit/9c837b7d0e2e2dffae804f3df49c4aeefe4743c0
DIFF: https://github.com/llvm/llvm-project/commit/9c837b7d0e2e2dffae804f3df49c4aeefe4743c0.diff
LOG: [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
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index e335d7c181995d..f8aa72605a7c21 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);
More information about the llvm-commits
mailing list