Skip to content

Commit d1d0e13

Browse files
committed
[LV] Move packScalarIntoVectorValue to VPTransformState (NFC).
This moves packScalarIntoVectorValue from ILV to the more approriate VPTransformState.
1 parent b9982b2 commit d1d0e13

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,6 @@ class InnerLoopVectorizer {
556556
const VPIteration &Instance,
557557
VPTransformState &State);
558558

559-
/// Construct the vector value of a scalarized value \p V one lane at a time.
560-
void packScalarIntoVectorValue(VPValue *Def, const VPIteration &Instance,
561-
VPTransformState &State);
562-
563559
/// Try to vectorize interleaved access group \p Group with the base address
564560
/// given in \p Addr, optionally masking the vector operations if \p
565561
/// BlockInMask is non-null. Use \p State to translate given VPValues to IR
@@ -2524,17 +2520,6 @@ static bool isIndvarOverflowCheckKnownFalse(
25242520
return false;
25252521
}
25262522

2527-
void InnerLoopVectorizer::packScalarIntoVectorValue(VPValue *Def,
2528-
const VPIteration &Instance,
2529-
VPTransformState &State) {
2530-
Value *ScalarInst = State.get(Def, Instance);
2531-
Value *VectorValue = State.get(Def, Instance.Part);
2532-
VectorValue = Builder.CreateInsertElement(
2533-
VectorValue, ScalarInst,
2534-
Instance.Lane.getAsRuntimeExpr(State.Builder, VF));
2535-
State.set(Def, VectorValue, Instance.Part);
2536-
}
2537-
25382523
// Return whether we allow using masked interleave-groups (for dealing with
25392524
// strided loads/stores that reside in predicated blocks, or for dealing
25402525
// with gaps).
@@ -9619,7 +9604,7 @@ void VPReplicateRecipe::execute(VPTransformState &State) {
96199604
VectorType::get(UI->getType(), State.VF));
96209605
State.set(this, Poison, State.Instance->Part);
96219606
}
9622-
State.ILV->packScalarIntoVectorValue(this, *State.Instance, State);
9607+
State.packScalarIntoVectorValue(this, *State.Instance);
96239608
}
96249609
return;
96259610
}
@@ -9929,7 +9914,7 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part) {
99299914
Value *Undef = PoisonValue::get(VectorType::get(LastInst->getType(), VF));
99309915
set(Def, Undef, Part);
99319916
for (unsigned Lane = 0; Lane < VF.getKnownMinValue(); ++Lane)
9932-
ILV->packScalarIntoVectorValue(Def, {Part, Lane}, *this);
9917+
packScalarIntoVectorValue(Def, {Part, Lane});
99339918
VectorValue = get(Def, Part);
99349919
}
99359920
Builder.restoreIP(OldIP);

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ void VPTransformState::setDebugLocFromInst(const Value *V) {
291291
Builder.SetCurrentDebugLocation(DIL);
292292
}
293293

294+
void VPTransformState::packScalarIntoVectorValue(VPValue *Def,
295+
const VPIteration &Instance) {
296+
Value *ScalarInst = get(Def, Instance);
297+
Value *VectorValue = get(Def, Instance.Part);
298+
VectorValue = Builder.CreateInsertElement(
299+
VectorValue, ScalarInst, Instance.Lane.getAsRuntimeExpr(Builder, VF));
300+
set(Def, VectorValue, Instance.Part);
301+
}
302+
294303
BasicBlock *
295304
VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
296305
// BB stands for IR BasicBlocks. VPBB stands for VPlan VPBasicBlocks.

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ struct VPTransformState {
352352
/// Set the debug location in the builder using the debug location in \p V.
353353
void setDebugLocFromInst(const Value *V);
354354

355+
/// Construct the vector value of a scalarized value \p V one lane at a time.
356+
void packScalarIntoVectorValue(VPValue *Def, const VPIteration &Instance);
357+
355358
/// Hold state information used when constructing the CFG of the output IR,
356359
/// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
357360
struct CFGState {

0 commit comments

Comments
 (0)