[PATCH] D79720: [IndVarSimplify][LoopUtils] Track rewrite cost per unique BB (PR45835)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 09:40:00 PDT 2020


lebedev.ri added a comment.

Thank you for looking into it!

(In reply to dmajor from https://bugs.llvm.org/show_bug.cgi?id=45835#c3)

> For anyone curious where the different values of HighCost come from...
> 
> When we're recursively looking at the second NAry operand [0] of the first
>  value, that operand is considered high cost due to [1]:
> 
>   if (isa<SCEVMinMaxExpr>(S))
>     return true;
>    
> 
> When we're looking at the second NAry operand of the second value, it is
>  considered low cost due to [2]:
> 
>   // If we can find an existing value for this scev available at the point "At"
>   // then consider the expression cheap.
>   if (At && getRelatedExistingExpansion(S, At, L))
>     return false;

Yes, but it is still not obvious to me as to why that happens?
It's the same PHI node, we are asking about the same value, for the same basic block.
Why do we not find expansion first time but do find it second time?
Did we perform some expansion inbetween?

> [0]
>  https://github.com/llvm/llvm-project/blob/release/10.x/llvm/lib/Analysis/
>  ScalarEvolutionExpander.cpp#L2198-L2205
>  [1]
>  https://github.com/llvm/llvm-project/blob/release/10.x/llvm/lib/Analysis/
>  ScalarEvolutionExpander.cpp#L2193-L2196
>  [2]
>  https://github.com/llvm/llvm-project/blob/release/10.x/llvm/lib/Analysis/
>  ScalarEvolutionExpander.cpp#L2135-L2138




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79720/new/

https://reviews.llvm.org/D79720





More information about the llvm-commits mailing list