[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) {
----------------
ayalz wrote:

Perhaps something like the following would be clearer:

```
    // First deal with generating multiple values - per all lanes.
    if (doesGeneratePerAllLanes()) {
      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;
    }

    // Now deal with generating a single value - per first lane or per part.
    Value *GeneratedValue = DoesGeneratePerFirstLaneOnly ?
      generatePerLane(State, VPIteration(Part, 0)) :
      generatePerPart(State, Part);
    ...
```
?

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


More information about the llvm-commits mailing list