[llvm] [LV] Ensure VPInstruction::usesFirstLaneOnly behaves correctly for WidePtrAdd (PR #169344)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 25 04:20:25 PST 2025
fhahn wrote:
> > Hmm, for a scalar plan, we should probably not emit a wide pointer add in the first place I think?
>
> I did wonder that, but I'm not familiar with this new WidePtrAdd and I think I also see normal ptr-add recipes too so it seemed to be at least consistent with that.
For scalar VFs, it should be scalarized, not creating wide pointer adds. I think something like below should make sure we correctly scalarize
```
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 9174058baad6..af0a5bba3004 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -717,7 +717,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
// Replace wide pointer inductions which have only their scalars used by
// PtrAdd(IndStart, ScalarIVSteps (0, Step)).
if (auto *PtrIV = dyn_cast<VPWidenPointerInductionRecipe>(&Phi)) {
- if (!PtrIV->onlyScalarsGenerated(Plan.hasScalableVF()))
+ if (!Plan.hasScalarVFOnly() && !PtrIV->onlyScalarsGenerated(Plan.hasScalableVF()))
continue;
const InductionDescriptor &ID = PtrIV->getInductionDescriptor();
```
https://github.com/llvm/llvm-project/pull/169344
More information about the llvm-commits
mailing list