[llvm] [VPlan] Explicitly handle scalar pointer inductions. (PR #83068)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 10 16:55:08 PDT 2024


================
@@ -515,15 +536,32 @@ void VPInstruction::execute(VPTransformState &State) {
   if (hasFastMathFlags())
     State.Builder.setFastMathFlags(getFastMathFlags());
   for (unsigned Part = 0; Part < State.UF; ++Part) {
-    Value *GeneratedValue = generateInstruction(State, Part);
+    bool OnlyFirstLaneDefined =
+        vputils::onlyFirstLaneUsed(this) ||
+        getOpcode() == VPInstruction::ComputeReductionResult;
+    if (doesGenerateScalars()) {
+      if (OnlyFirstLaneDefined) {
+        Value *P = generatePerLane(State, VPIteration(Part, 0));
+        State.set(this, P, Part, /*IsScalar*/ true);
+        continue;
+      }
+
+      for (unsigned Lane = 0, NumLanes = State.VF.getKnownMinValue();
+           Lane != NumLanes; ++Lane) {
+        Value *P = generatePerLane(State, VPIteration(Part, Lane));
+        State.set(this, P, VPIteration(Part, Lane));
+      }
+      continue;
+    }
+
+    Value *GeneratedValue = generatePerPart(State, Part);
     if (!hasResult())
       continue;
     assert(GeneratedValue && "generateInstruction must produce a value");
 
     bool IsVector = GeneratedValue->getType()->isVectorTy();
     State.set(this, GeneratedValue, Part, !IsVector);
-    assert((IsVector || getOpcode() == VPInstruction::ComputeReductionResult ||
-            State.VF.isScalar() || vputils::onlyFirstLaneUsed(this)) &&
+    assert((IsVector || OnlyFirstLaneDefined || State.VF.isScalar()) &&
            "scalar value but not only first lane used");
----------------
ayalz wrote:

```suggestion
           "scalar value but not only first lane defined");
```

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


More information about the llvm-commits mailing list