Skip to content

Commit 7ca6490

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

File tree

1 file changed

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

1 file changed

+7
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,9 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
18601860
class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
18611861
TruncInst *Trunc;
18621862

1863+
// If this recipe is unrolled it will have 2 additional operands.
1864+
bool isUnrolled() const { return getNumOperands() == 5; }
1865+
18631866
public:
18641867
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
18651868
VPValue *VF, const InductionDescriptor &IndDesc,
@@ -1908,9 +1911,9 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
19081911
const VPValue *getVFValue() const { return getOperand(2); }
19091912

19101913
VPValue *getSplatVFValue() {
1911-
// If the recipe has been unrolled (4 operands), return the VPValue for the
1912-
// induction increment.
1913-
return getNumOperands() == 5 ? getOperand(3) : nullptr;
1914+
// If the recipe has been unrolled return the VPValue for the induction
1915+
// increment.
1916+
return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
19141917
}
19151918

19161919
/// Returns the first defined value as TruncInst, if it is one or nullptr
@@ -1932,7 +1935,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
19321935
/// the last unrolled part, if it exists. Returns itself if unrolling did not
19331936
/// take place.
19341937
VPValue *getLastUnrolledPartOperand() {
1935-
return getNumOperands() == 5 ? getOperand(4) : this;
1938+
return isUnrolled() ? getOperand(getNumOperands() - 1) : this;
19361939
}
19371940
};
19381941

0 commit comments

Comments
 (0)