[PATCH] D157062: [ValueTracking] Improve the coverage of isKnownToBeAPowerOfTwo for vscale

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 18:04:44 PDT 2023


Allen created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Allen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

this PR tries to match the following pattern, seperate from D156881 <https://reviews.llvm.org/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.


https://reviews.llvm.org/D157062

Files:
  llvm/lib/Analysis/ValueTracking.cpp


Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2018,7 +2018,8 @@
       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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157062.547069.patch
Type: text/x-patch
Size: 579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230804/bb78c471/attachment.bin>


More information about the llvm-commits mailing list