[PATCH] D118808: Loop Strength Reduce - Optimize unused IVs to final values in the exit block with SCEV
Zaara Syeda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 3 08:37:12 PST 2022
syzaara added a comment.
Herald added a project: All.
In D118808#3338917 <https://reviews.llvm.org/D118808#3338917>, @Whitney wrote:
> Is it possible to abstract the portion of the code in IndVarSimplify to simplify this code pattern, and call that function instead of creating your own `ReplaceExitPHIsWithFinalVal`?
IndVarSimply calls rewriteLoopExitValues from LoopUtils to do this optimization. I tried to call the same function in LoopStrengthReduce, however rewriteLoopExitValues asserts that it requires: L->isRecursivelyLCSSAForm(*DT, *LI).
When calling rewriteLoopExitValues from LoopStrengthReduce, this assert is not met.
================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5644
+ continue;
+ for (auto U : IV->users()) {
+ if (U != IVNext) {
----------------
Whitney wrote:
> In what situation, that IV only has a single use (`IV->getNumUses() != 1`) and one of the incoming values of `IV` is `IVNext`, but `U != IVNext`?
There seems to be cases like this in the lit tests. Here an example from llvm/test/CodeGen/PowerPC/common-chain.ll
Exit block includes:
```
%add23.3.lcssa = phi i64 [ %add23.3, %for.body ]
```
So %add23.3 is what we are looking to replace.
for.body include these instructions:
```
%inc.addr.050 = phi i64 [ %inc4, %for.body.preheader.new ], [ %add23.3, %for.body ]
%add23 = add nsw i64 %inc.addr.050, %inc4
%add23.3 = add i64 %add23.2, %inc4
```
The IV here is: %inc.addr.050 and it has only one use of:
%add23 = add nsw i64 %inc.addr.050, %inc4
which is not the same as IVNext: %add23.3
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118808/new/
https://reviews.llvm.org/D118808
More information about the llvm-commits
mailing list