-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[VPlan] Replace ExtractFromEnd with Extract(Last|Penultimate)Element (NFC). #137030
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 1 commit
876f977
80d1d0e
65178dd
20740c7
e5ecd86
1a5a728
733f4b5
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 |
|---|---|---|
|
|
@@ -878,10 +878,10 @@ class VPInstruction : public VPRecipeWithIRFlags, | |
| Broadcast, | ||
| ComputeFindLastIVResult, | ||
| ComputeReductionResult, | ||
| // Takes the VPValue to extract from as first operand and the lane or part | ||
| // to extract as second operand, counting from the end starting with 1 for | ||
| // last. The second operand must be a positive constant and <= VF. | ||
| ExtractFromEnd, | ||
| // Extracts the last lane from its operand. | ||
| ExtractLastLane, | ||
| // Extracts the second-to-last lane from its operand. | ||
| ExtractPenultimateLane, | ||
|
||
| LogicalAnd, // Non-poison propagating logical And. | ||
| // Add an offset in bytes (second operand) to a base pointer (first | ||
| // operand). Only generates scalar values (either for the first lane only or | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -725,10 +725,9 @@ Value *VPInstruction::generate(VPTransformState &State) { | |||||||
|
|
||||||||
| return ReducedPartRdx; | ||||||||
| } | ||||||||
| case VPInstruction::ExtractFromEnd: { | ||||||||
| auto *CI = cast<ConstantInt>(getOperand(1)->getLiveInIRValue()); | ||||||||
| unsigned Offset = CI->getZExtValue(); | ||||||||
| assert(Offset > 0 && "Offset from end must be positive"); | ||||||||
| case VPInstruction::ExtractLastLane: | ||||||||
| case VPInstruction::ExtractPenultimateLane: { | ||||||||
| unsigned Offset = getOpcode() == VPInstruction::ExtractLastLane ? 1 : 2; | ||||||||
| Value *Res; | ||||||||
| if (State.VF.isVector()) { | ||||||||
| assert(Offset <= State.VF.getKnownMinValue() && | ||||||||
|
|
@@ -854,7 +853,8 @@ InstructionCost VPInstruction::computeCost(ElementCount VF, | |||||||
| } | ||||||||
|
|
||||||||
| bool VPInstruction::isVectorToScalar() const { | ||||||||
| return getOpcode() == VPInstruction::ExtractFromEnd || | ||||||||
| return getOpcode() == VPInstruction::ExtractLastLane || | ||||||||
| getOpcode() == VPInstruction::ExtractPenultimateLane || | ||||||||
| getOpcode() == Instruction::ExtractElement || | ||||||||
| getOpcode() == VPInstruction::FirstActiveLane || | ||||||||
| getOpcode() == VPInstruction::ComputeFindLastIVResult || | ||||||||
|
|
@@ -924,7 +924,8 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const { | |||||||
| case VPInstruction::AnyOf: | ||||||||
| case VPInstruction::CalculateTripCountMinusVF: | ||||||||
| case VPInstruction::CanonicalIVIncrementForPart: | ||||||||
| case VPInstruction::ExtractFromEnd: | ||||||||
| case VPInstruction::ExtractLastLane: | ||||||||
| case VPInstruction::ExtractPenultimateLane: | ||||||||
| case VPInstruction::FirstActiveLane: | ||||||||
| case VPInstruction::FirstOrderRecurrenceSplice: | ||||||||
| case VPInstruction::LogicalAnd: | ||||||||
|
|
@@ -1042,8 +1043,11 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent, | |||||||
| case VPInstruction::Broadcast: | ||||||||
| O << "broadcast"; | ||||||||
| break; | ||||||||
| case VPInstruction::ExtractFromEnd: | ||||||||
| O << "extract-from-end"; | ||||||||
| case VPInstruction::ExtractLastLane: | ||||||||
| O << "extract-last-lane"; | ||||||||
| break; | ||||||||
| case VPInstruction::ExtractPenultimateLane: | ||||||||
| O << "extract-penultimate-lane"; | ||||||||
| break; | ||||||||
| case VPInstruction::ComputeFindLastIVResult: | ||||||||
| O << "compute-find-last-iv-result"; | ||||||||
|
|
@@ -1143,12 +1147,7 @@ void VPIRInstruction::extractLastLaneOfOperand(VPBuilder &Builder) { | |||||||
| assert(getNumOperands() == 1 && "must have a single operand"); | ||||||||
| VPValue *Exiting = getOperand(0); | ||||||||
| if (!Exiting->isLiveIn()) { | ||||||||
|
||||||||
| if (!Exiting->isLiveIn()) { | |
| if (Exiting->isLiveIn()) | |
| return; |
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.
done thanks
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -337,14 +337,19 @@ void UnrollState::unrollBlock(VPBlockBase *VPB) { | |||||||
| continue; | ||||||||
| } | ||||||||
| VPValue *Op0; | ||||||||
| if (match(&R, m_VPInstruction<VPInstruction::ExtractFromEnd>( | ||||||||
| m_VPValue(Op0), m_VPValue(Op1)))) { | ||||||||
| if (match(&R, m_VPInstruction<VPInstruction::ExtractLastLane>( | ||||||||
| m_VPValue(Op0))) || | ||||||||
| match(&R, m_VPInstruction<VPInstruction::ExtractPenultimateLane>( | ||||||||
| m_VPValue(Op0)))) { | ||||||||
| addUniformForAllParts(cast<VPSingleDefRecipe>(&R)); | ||||||||
| if (Plan.hasScalarVFOnly()) { | ||||||||
|
Collaborator
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. Handle simpler vector VF case first?
Contributor
Author
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. Can do separately, leaving as-is for now to not pull in unrelated changes. |
||||||||
| // Extracting from end with VF = 1 implies retrieving the scalar part UF | ||||||||
| // - Op1. | ||||||||
|
||||||||
| // Extracting from end with VF = 1 implies retrieving the scalar part UF | |
| // - Op1. | |
| // Extracting from end with VF = 1 implies retrieving the last or penultimate scalar part (UF-1 or UF-2). |
In this case we're extracting a last/penultimate "Part" rather than "Lane". Perhaps better call the opcodes ExtractLast/ExtractPenultimate, or ExtractLastElement/ExtractPenultimateElement.
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.
Updated, thanks
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.
Trying to simplify:
| unsigned Offset = | |
| auto *I = dyn_cast<VPInstruction>(&R); // Place above for reuse. Similar to H below. | |
| unsigned Offset = I->getOpcode() == VPInstruction::ExtractLast ? 1 : 2; |
consistent with how VPInstruction::generate() computes Offset?
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.
done, using cast, thanks
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.
Extract last applies to both lane (when VF>1) and part (when VF=1), so better call it
ExtractLast?Extract penultimate applies to lane only (demands VF>1), so
ExtractPenultimateLaneis accurate.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.
Updated, thanks