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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 06:57:35 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();
----------------
fhahn wrote:

Updated to use `OnlyGenerateFirstLane`; in those cases a scalar must be returned and set.

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


More information about the llvm-commits mailing list