-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[VPlan] Add ComputeAnyOfResult VPInstruction (NFC) #141932
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -604,6 +604,20 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
return Builder.CreateVectorSplat( | ||
State.VF, State.get(getOperand(0), /*IsScalar*/ true), "broadcast"); | ||
} | ||
case VPInstruction::ComputeAnyOfResult: { | ||
// FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary | ||
// and will be removed by breaking up the recipe further. | ||
auto *PhiR = cast<VPReductionPHIRecipe>(getOperand(0)); | ||
auto *OrigPhi = cast<PHINode>(PhiR->getUnderlyingValue()); | ||
Value *ReducedPartRdx = State.get(getOperand(2)); | ||
for (unsigned Idx = 3; Idx < getNumOperands(); ++Idx) | ||
ReducedPartRdx = Builder.CreateBinOp( | ||
(Instruction::BinaryOps)RecurrenceDescriptor::getOpcode( | ||
RecurKind::AnyOf), | ||
State.get(getOperand(Idx)), ReducedPartRdx, "bin.rdx"); | ||
return createAnyOfReduction(Builder, ReducedPartRdx, | ||
State.get(getOperand(1), VPLane(0)), OrigPhi); | ||
} | ||
Comment on lines
+607
to
+620
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think it’s worth unifying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With VPInstruction we cannot easily add the recurrence kind to the recipe. I think it would be good to keep the separate opcodes, especially if we add the sentinel value in #142291. |
||
case VPInstruction::ComputeFindLastIVResult: { | ||
// FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary | ||
// and will be removed by breaking up the recipe further. | ||
|
@@ -681,18 +695,11 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
|
||
// Create the reduction after the loop. Note that inloop reductions create | ||
// the target reduction in the loop using a Reduction recipe. | ||
if ((State.VF.isVector() || | ||
RecurrenceDescriptor::isAnyOfRecurrenceKind(RK)) && | ||
!PhiR->isInLoop()) { | ||
if (State.VF.isVector() && !PhiR->isInLoop()) { | ||
// TODO: Support in-order reductions based on the recurrence descriptor. | ||
// All ops in the reduction inherit fast-math-flags from the recurrence | ||
// descriptor. | ||
if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RK)) | ||
ReducedPartRdx = | ||
createAnyOfReduction(Builder, ReducedPartRdx, | ||
RdxDesc.getRecurrenceStartValue(), OrigPhi); | ||
else | ||
ReducedPartRdx = createSimpleReduction(Builder, ReducedPartRdx, RK); | ||
ReducedPartRdx = createSimpleReduction(Builder, ReducedPartRdx, RK); | ||
|
||
// If the reduction can be performed in a smaller type, we need to extend | ||
// the reduction to the wider type before we branch to the original loop. | ||
|
@@ -830,6 +837,7 @@ bool VPInstruction::isVectorToScalar() const { | |
getOpcode() == VPInstruction::ExtractPenultimateElement || | ||
getOpcode() == Instruction::ExtractElement || | ||
getOpcode() == VPInstruction::FirstActiveLane || | ||
getOpcode() == VPInstruction::ComputeAnyOfResult || | ||
getOpcode() == VPInstruction::ComputeFindLastIVResult || | ||
getOpcode() == VPInstruction::ComputeReductionResult || | ||
getOpcode() == VPInstruction::AnyOf; | ||
|
@@ -925,6 +933,7 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const { | |
return true; | ||
case VPInstruction::PtrAdd: | ||
return Op == getOperand(0) || vputils::onlyFirstLaneUsed(this); | ||
case VPInstruction::ComputeAnyOfResult: | ||
case VPInstruction::ComputeFindLastIVResult: | ||
return Op == getOperand(1); | ||
}; | ||
|
@@ -1005,6 +1014,9 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent, | |
case VPInstruction::ExtractPenultimateElement: | ||
O << "extract-penultimate-element"; | ||
break; | ||
case VPInstruction::ComputeAnyOfResult: | ||
O << "compute-anyof-result"; | ||
break; | ||
case VPInstruction::ComputeFindLastIVResult: | ||
O << "compute-find-last-iv-result"; | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need a assertion that check if RdxResult is a VPInstruction::ComputeAnyOfResult/ComputeFindLastIVResult?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, thanks