[llvm] 9c837b7 - [ValueTracking] Improve the coverage of isKnownToBeAPowerOfTwo for vscale

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 07:28:19 PDT 2023


This appears wrong, please revert.  Also, no test cases?

The incorrect case is: shl (vscale), 64.  This produces zero, not a 
power of two.

The added case needs to only apply when OrZero is true.

Philip


On 8/3/23 18:11, via llvm-commits wrote:
> 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);
>
>
>          
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list