[flang-commits] [lld] [flang] [lldb] [compiler-rt] [mlir] [polly] [clang] [llvm] [openmp] [VPlan] Compute scalable VF in preheader for induction increment. (PR #74762)

via flang-commits flang-commits at lists.llvm.org
Fri Dec 8 15:12:59 PST 2023


================
@@ -340,8 +340,14 @@ Value *VPInstruction::generateInstruction(VPTransformState &State,
       auto *Phi = State.get(getOperand(0), 0);
       // The loop step is equal to the vectorization factor (num of SIMD
       // elements) times the unroll factor (num of SIMD instructions).
-      Value *Step =
-          createStepForVF(Builder, Phi->getType(), State.VF, State.UF);
+      Value *Step;
+      {
+        BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
+        IRBuilder<> PHBuilder(VectorPH->getTerminator());
+        // Step is loop-invariant, calls to vscale will be placed in the
+        // preheader.
+        Step = createStepForVF(PHBuilder, Phi->getType(), State.VF, State.UF);
+      }
----------------
ayalz wrote:

```suggestion
      // Step is loop-invariant, calls to vscale will be placed in the preheader.
      BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
      IRBuilder<> PHBuilder(VectorPH->getTerminator());
      Value *Step = createStepForVF(PHBuilder, Phi->getType(), State.VF, State.UF);
```

(no need for the bracketed block, which was needed for the point guard.)

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


More information about the flang-commits mailing list