[llvm] [VPlan] Use InstSimplifyFolder instead of TargetFolder (PR #141222)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Sat May 31 06:05:54 PDT 2025
artagnon wrote:
The issue is that we have this VPlan:
```
<x1> vector loop: {
vector.body:
EMIT vp<%6> = CANONICAL-INDUCTION ir<0>, vp<%index.next>
Successor(s): pred.sdiv
<xVFxUF> pred.sdiv: {
pred.sdiv.entry:
BRANCH-ON-MASK vp<%5>
Successor(s): pred.sdiv.if, pred.sdiv.continue
pred.sdiv.if:
REPLICATE ir<%sdiv> = sdiv ir<%sext.0>, ir<%zext.true> (S->V)
Successor(s): pred.sdiv.continue
pred.sdiv.continue:
PHI-PREDICATED-INSTRUCTION vp<%7> = ir<%sdiv>
No successors
}
```
where `REPLICATE ir<%sdiv> = sdiv ir<%sext.0>, ir<%zext.true>` gets simplified to the Value `%sext.0`, and RAUW changes the PredPHI to `PHI-PREDICATED-INSTRUCTION vp<%7> = ir<%sext.0>`: this PredPHI would have got simplified with TargetFolder before this commit as follows.
```cpp
if (auto *PredPHI = dyn_cast<VPPredInstPHIRecipe>(&R)) {
VPlan *Plan = R.getParent()->getPlan();
VPValue *Op = PredPHI->getOperand(0);
if (!Op->isLiveIn() || !Op->getLiveInIRValue())
return;
if (auto *C = dyn_cast<Constant>(Op->getLiveInIRValue()))
PredPHI->replaceAllUsesWith(Plan->getOrAddLiveIn(C));
}
```
However, the match against a Constant fails, and the PredPHI isn't simplified. This should be an easy fix, which I will post shortly.
https://github.com/llvm/llvm-project/pull/141222
More information about the llvm-commits
mailing list