[llvm] [VPlan] Compute scalable VF in preheader for induction increment. (PR #74762)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 14:22:39 PST 2023
================
@@ -340,8 +340,13 @@ 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<>::InsertPointGuard Guard(Builder);
+ Builder.SetInsertPoint(VectorPH->getTerminator());
----------------
ayalz wrote:
This is fine. Can alternatively define a separate builder set to the vector preheader to serve createStepForVF, independent of `Builder` which serves CreateAdd.
Perhaps worth a comment that step for VF must be loop invariant, and for scalable VF's generates a call to vscale which should be placed in the preheader.
https://github.com/llvm/llvm-project/pull/74762
More information about the llvm-commits
mailing list