Skip to content

Commit 1dc1eb2

Browse files
committed
Add isUnrolled() helper, remove hard coded operand indices
1 parent dab3f14 commit 1dc1eb2

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
@@ -1863,9 +1863,9 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
18631863
void setStepVector(VPValue *V) { setOperand(3, V); }
18641864

18651865
VPValue *getSplatVFValue() {
1866-
// If the recipe has been unrolled (4 operands), return the VPValue for the
1866+
// If the recipe has been unrolled, return the VPValue for the
18671867
// induction increment.
1868-
return getNumOperands() == 6 ? getOperand(4) : nullptr;
1868+
return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
18691869
}
18701870

18711871
/// Returns the first defined value as TruncInst, if it is one or nullptr
@@ -1887,8 +1887,11 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
18871887
/// the last unrolled part, if it exists. Returns itself if unrolling did not
18881888
/// take place.
18891889
VPValue *getLastUnrolledPartOperand() {
1890-
return getNumOperands() == 6 ? getOperand(5) : this;
1890+
return isUnrolled() ? getOperand(getNumOperands() - 1) : this;
18911891
}
1892+
1893+
private:
1894+
bool isUnrolled() const { return getNumOperands() == 6; }
18921895
};
18931896

18941897
class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe,

0 commit comments

Comments
 (0)