Skip to content

Commit 1a2ec3e

Browse files
committed
[VPlan] Factor out isUnrolled() helper in VPWidenIntOrFpInductionRecipe. NFC
Split off from #129508, this generalizes getSplatVFValue and getLastUnrolledPartOperand so they don't need changed if another operand is added.
1 parent a129ca7 commit 1a2ec3e

File tree

1 file changed

+4
-2
lines changed
  • llvm/lib/Transforms/Vectorize

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,8 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
18511851
class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
18521852
TruncInst *Trunc;
18531853

1854+
bool isUnrolled() const { return getNumOperands() == 5; }
1855+
18541856
public:
18551857
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
18561858
VPValue *VF, const InductionDescriptor &IndDesc,
@@ -1901,7 +1903,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
19011903
VPValue *getSplatVFValue() {
19021904
// If the recipe has been unrolled (4 operands), return the VPValue for the
19031905
// induction increment.
1904-
return getNumOperands() == 5 ? getOperand(3) : nullptr;
1906+
return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
19051907
}
19061908

19071909
/// Returns the first defined value as TruncInst, if it is one or nullptr
@@ -1923,7 +1925,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
19231925
/// the last unrolled part, if it exists. Returns itself if unrolling did not
19241926
/// take place.
19251927
VPValue *getLastUnrolledPartOperand() {
1926-
return getNumOperands() == 5 ? getOperand(4) : this;
1928+
return isUnrolled() ? getOperand(getNumOperands() - 1) : this;
19271929
}
19281930
};
19291931

0 commit comments

Comments
 (0)