[PATCH] D103007: [LoopUtils] Avoid expanding complicated SCEVNAry when rewriteLoopExitValues

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 05:43:15 PDT 2021


lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

In D103007#2776920 <https://reviews.llvm.org/D103007#2776920>, @guopeilin wrote:

> In D103007#2776571 <https://reviews.llvm.org/D103007#2776571>, @nikic wrote:
>
>> Why is this not already covered by the isHighCostExpansion() check?
>
> Firstly,within the function `isHighCostExpansion`, only the SCEVUDivExpr and SCEVMinMaxExpr could have the chance to return true.

You are looking at the wrong function.

> Secondly, even though function isHighCostExpansion return true, the result is used in the following code:
>
>   // Only do the rewrite when the ExitValue can be expanded cheaply.
>   // If LoopCanBeDel is true, rewrite exit value aggressively.
>   if (ReplaceExitValue == OnlyCheapRepl && !LoopCanBeDel && Phi.HighCost) {
>     DeadInsts.push_back(ExitVal);
>     continue;
>   }
>
> And in this case, the variable LoopCanBeDel  is true,  this means we will expand anyway.
> So I guess we need some early-return way to avoid this extremely complicated cases.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103007



More information about the llvm-commits mailing list