Skip to content

Commit 5d307e4

Browse files
committed
Add isUnrolled() helper, remove hard coded operand indices
1 parent 68bbf28 commit 5d307e4

File tree

1 file changed

+6
-3
lines changed
  • llvm/lib/Transforms/Vectorize

1 file changed

+6
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,9 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
18871887
void setStepVector(VPValue *V) { setOperand(3, V); }
18881888

18891889
VPValue *getSplatVFValue() {
1890-
// If the recipe has been unrolled (4 operands), return the VPValue for the
1890+
// If the recipe has been unrolled, return the VPValue for the
18911891
// induction increment.
1892-
return getNumOperands() == 6 ? getOperand(4) : nullptr;
1892+
return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
18931893
}
18941894

18951895
/// Returns the first defined value as TruncInst, if it is one or nullptr
@@ -1911,8 +1911,11 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
19111911
/// the last unrolled part, if it exists. Returns itself if unrolling did not
19121912
/// take place.
19131913
VPValue *getLastUnrolledPartOperand() {
1914-
return getNumOperands() == 6 ? getOperand(5) : this;
1914+
return isUnrolled() ? getOperand(getNumOperands() - 1) : this;
19151915
}
1916+
1917+
private:
1918+
bool isUnrolled() const { return getNumOperands() == 6; }
19161919
};
19171920

19181921
class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe,

0 commit comments

Comments
 (0)