Skip to content

Commit e6d5dcf

Browse files
committed
[LV] Pass kind and induction binop to emitTransformedIndex (NFC).
Explicitly pass InductionKind and InductionBinOp to emitTransformedIndex. Only those values are needed from the induction descriptor. This makes explicit what is needed for the function and allows future use cases where the a full induction descriptor object is not available.
1 parent 8901eb2 commit e6d5dcf

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,9 +2382,11 @@ static void buildScalarSteps(Value *ScalarIV, Value *Step,
23822382
/// For pointer induction, returns StartValue[Index * StepValue].
23832383
/// FIXME: The newly created binary instructions should contain nsw/nuw
23842384
/// flags, which can be found from the original scalar operations.
2385-
static Value *emitTransformedIndex(IRBuilderBase &B, Value *Index,
2386-
Value *StartValue, Value *Step,
2387-
const InductionDescriptor &ID) {
2385+
static Value *
2386+
emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
2387+
Value *Step,
2388+
InductionDescriptor::InductionKind InductionKind,
2389+
BinaryOperator *InductionBinOp) {
23882390
Type *StepTy = Step->getType();
23892391
Value *CastedIndex = StepTy->isIntegerTy()
23902392
? B.CreateSExtOrTrunc(Index, StepTy)
@@ -2428,7 +2430,7 @@ static Value *emitTransformedIndex(IRBuilderBase &B, Value *Index,
24282430
return B.CreateMul(X, Y);
24292431
};
24302432

2431-
switch (ID.getKind()) {
2433+
switch (InductionKind) {
24322434
case InductionDescriptor::IK_IntInduction: {
24332435
assert(!isa<VectorType>(Index->getType()) &&
24342436
"Vector indices not supported for integer inductions yet");
@@ -2446,7 +2448,6 @@ static Value *emitTransformedIndex(IRBuilderBase &B, Value *Index,
24462448
assert(!isa<VectorType>(Index->getType()) &&
24472449
"Vector indices not supported for FP inductions yet");
24482450
assert(Step->getType()->isFloatingPointTy() && "Expected FP Step value");
2449-
auto InductionBinOp = ID.getInductionBinOp();
24502451
assert(InductionBinOp &&
24512452
(InductionBinOp->getOpcode() == Instruction::FAdd ||
24522453
InductionBinOp->getOpcode() == Instruction::FSub) &&
@@ -3118,15 +3119,16 @@ PHINode *InnerLoopVectorizer::createInductionResumeValue(
31183119
if (II.getInductionBinOp() && isa<FPMathOperator>(II.getInductionBinOp()))
31193120
B.setFastMathFlags(II.getInductionBinOp()->getFastMathFlags());
31203121

3121-
EndValue =
3122-
emitTransformedIndex(B, VectorTripCount, II.getStartValue(), Step, II);
3122+
EndValue = emitTransformedIndex(B, VectorTripCount, II.getStartValue(),
3123+
Step, II.getKind(), II.getInductionBinOp());
31233124
EndValue->setName("ind.end");
31243125

31253126
// Compute the end value for the additional bypass (if applicable).
31263127
if (AdditionalBypass.first) {
31273128
B.SetInsertPoint(&(*AdditionalBypass.first->getFirstInsertionPt()));
3128-
EndValueFromAdditionalBypass = emitTransformedIndex(
3129-
B, AdditionalBypass.second, II.getStartValue(), Step, II);
3129+
EndValueFromAdditionalBypass =
3130+
emitTransformedIndex(B, AdditionalBypass.second, II.getStartValue(),
3131+
Step, II.getKind(), II.getInductionBinOp());
31303132
EndValueFromAdditionalBypass->setName("ind.end");
31313133
}
31323134
}
@@ -3340,7 +3342,8 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
33403342
Value *Step = StepVPV->isLiveIn() ? StepVPV->getLiveInIRValue()
33413343
: State.get(StepVPV, {0, 0});
33423344
Value *Escape =
3343-
emitTransformedIndex(B, CountMinusOne, II.getStartValue(), Step, II);
3345+
emitTransformedIndex(B, CountMinusOne, II.getStartValue(), Step,
3346+
II.getKind(), II.getInductionBinOp());
33443347
Escape->setName("ind.escape");
33453348
MissingVals[UI] = Escape;
33463349
}
@@ -9408,7 +9411,8 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
94089411

94099412
Value *Step = State.get(getOperand(1), VPIteration(Part, Lane));
94109413
Value *SclrGep = emitTransformedIndex(
9411-
State.Builder, GlobalIdx, IndDesc.getStartValue(), Step, IndDesc);
9414+
State.Builder, GlobalIdx, IndDesc.getStartValue(), Step,
9415+
IndDesc.getKind(), IndDesc.getInductionBinOp());
94129416
SclrGep->setName("next.gep");
94139417
State.set(this, SclrGep, VPIteration(Part, Lane));
94149418
}
@@ -9482,9 +9486,9 @@ void VPDerivedIVRecipe::execute(VPTransformState &State) {
94829486

94839487
Value *Step = State.get(getStepValue(), VPIteration(0, 0));
94849488
Value *CanonicalIV = State.get(getCanonicalIV(), VPIteration(0, 0));
9485-
Value *DerivedIV =
9486-
emitTransformedIndex(State.Builder, CanonicalIV,
9487-
getStartValue()->getLiveInIRValue(), Step, IndDesc);
9489+
Value *DerivedIV = emitTransformedIndex(
9490+
State.Builder, CanonicalIV, getStartValue()->getLiveInIRValue(), Step,
9491+
IndDesc.getKind(), IndDesc.getInductionBinOp());
94889492
DerivedIV->setName("offset.idx");
94899493
if (ResultTy != DerivedIV->getType()) {
94909494
assert(Step->getType()->isIntegerTy() &&

0 commit comments

Comments
 (0)