-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[VPlan] Skip uses-scalars restriction if one of ops needs broadcast. #168246
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -1425,32 +1425,33 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) { | |
| continue; | ||
| } | ||
|
|
||
| // Skip recipes that aren't single scalars or don't have only their | ||
| // scalar results used. In the latter case, we would introduce extra | ||
| // broadcasts. | ||
| // Skip recipes that aren't single scalars or when conversion to | ||
| // single-scalar does not introduce additional broadcasts. That is, either | ||
| // only the scalars of the recipe are used, or at least one of the | ||
| // operands would require a broadcast. In the latter case, the | ||
| // single-scalar may need to be broadcasted, but another broadcast is | ||
| // removed. scalar results used. In the latter case, we would introduce | ||
| // extra broadcasts. | ||
| if (!vputils::isSingleScalar(RepOrWidenR) || | ||
|
Contributor
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. Could split this case out with an early continue? |
||
| !all_of(RepOrWidenR->users(), [RepOrWidenR](const VPUser *U) { | ||
| if (auto *Store = dyn_cast<VPWidenStoreRecipe>(U)) { | ||
| // VPWidenStore doesn't have users, and stores are always | ||
| // profitable to widen: hence, permitting address and mask | ||
| // operands, and single-scalar stored values is an important leaf | ||
| // condition. The assert must hold as we checked the RepOrWidenR | ||
| // operand against vputils::isSingleScalar. | ||
| assert(RepOrWidenR != Store->getStoredValue() || | ||
| vputils::isSingleScalar(Store->getStoredValue())); | ||
| return true; | ||
| } | ||
|
|
||
| if (auto *VPI = dyn_cast<VPInstruction>(U)) { | ||
| unsigned Opcode = VPI->getOpcode(); | ||
| if (Opcode == VPInstruction::ExtractLastElement || | ||
| Opcode == VPInstruction::ExtractLastLanePerPart || | ||
| Opcode == VPInstruction::ExtractPenultimateElement) | ||
| return true; | ||
| } | ||
|
|
||
| return U->usesScalars(RepOrWidenR); | ||
| })) | ||
| (!all_of(RepOrWidenR->users(), | ||
| [RepOrWidenR](const VPUser *U) { | ||
| if (auto *VPI = dyn_cast<VPInstruction>(U)) { | ||
| unsigned Opcode = VPI->getOpcode(); | ||
| if (Opcode == VPInstruction::ExtractLastElement || | ||
| Opcode == VPInstruction::ExtractLastLanePerPart || | ||
| Opcode == VPInstruction::ExtractPenultimateElement) | ||
| return true; | ||
| } | ||
|
|
||
| return U->usesScalars(RepOrWidenR); | ||
| }) && | ||
| none_of(RepOrWidenR->operands(), [RepOrWidenR](VPValue *Op) { | ||
| return Op->getSingleUser() == RepOrWidenR && | ||
| ((Op->isLiveIn() && | ||
| !isa<Constant>(Op->getLiveInIRValue())) || | ||
|
Comment on lines
+1450
to
+1451
Contributor
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. Why are non-constant live-ins special-cased again? Deserves a comment? |
||
| (isa<VPReplicateRecipe>(Op) && | ||
| cast<VPReplicateRecipe>(Op)->isSingleScalar())); | ||
|
Comment on lines
+1452
to
+1453
Contributor
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. Could hoist out a dyn_cast? |
||
| }))) | ||
| continue; | ||
|
|
||
| auto *Clone = new VPReplicateRecipe(RepOrWidenR->getUnderlyingInstr(), | ||
|
|
||
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.