[llvm] [LV] Ensure VPInstruction::usesFirstLaneOnly behaves correctly for WidePtrAdd (PR #169344)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 09:04:21 PST 2025


https://github.com/lukel97 approved this pull request.

LGTM. I think also the first operand should also always be scalar, but we need to change that in VPInstruction::generate too. I.e. I think in another PR we should do

```diff
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -976,7 +976,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
   }
   case VPInstruction::WidePtrAdd: {
     Value *Ptr =
-        State.get(getOperand(0), vputils::isSingleScalar(getOperand(0)));
+        State.get(getOperand(0), true);
     Value *Addend = State.get(getOperand(1));
     return Builder.CreatePtrAdd(Ptr, Addend, Name, getGEPNoWrapFlags());
   }
@@ -1360,7 +1360,7 @@ bool VPInstruction::usesFirstLaneOnly(const VPValue *Op) const {
     return Op == getOperand(0) || vputils::onlyFirstLaneUsed(this);
   case VPInstruction::WidePtrAdd:
     // WidePtrAdd supports scalar and vector base addresses.
-    return false;
+   return vputils::onlyFirstLaneUsed(this) || Op == getOperand(1);
   case VPInstruction::ComputeAnyOfResult:
   case VPInstruction::ComputeFindIVResult:
     return Op == getOperand(1);
```

https://github.com/llvm/llvm-project/pull/169344


More information about the llvm-commits mailing list