Skip to content

[VPlan] Factor out isUnrolled() helper in VPWidenIntOrFpInductionRecipe. NFC #137635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,9 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
TruncInst *Trunc;

// If this recipe is unrolled it will have 2 additional operands.
bool isUnrolled() const { return getNumOperands() == 5; }

public:
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
VPValue *VF, const InductionDescriptor &IndDesc,
Expand Down Expand Up @@ -1899,9 +1902,9 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
const VPValue *getVFValue() const { return getOperand(2); }

VPValue *getSplatVFValue() {
// If the recipe has been unrolled (4 operands), return the VPValue for the
// induction increment.
return getNumOperands() == 5 ? getOperand(3) : nullptr;
// If the recipe has been unrolled return the VPValue for the induction
// increment.
return isUnrolled() ? getOperand(getNumOperands() - 2) : nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I think the comment above also looks out of date because there are 5 operands. Might be worth cleaning this up while you're here? Or perhaps even just move the comment above isUnrolled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch, I've cleaned it up in b9b058d

}

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

Expand Down
Loading