-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[GlobalISel][AMDGPU] Import patterns with multiple defs #84171
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 |
---|---|---|
|
@@ -728,25 +728,34 @@ def : OpSelBinOpClampPat<saddsat, V_ADD_I16_e64>; | |
def : OpSelBinOpClampPat<ssubsat, V_SUB_I16_e64>; | ||
} // End SubtargetPredicate = isGFX9Plus | ||
|
||
// FIXME: GlobalISel in general does not handle instructions with 2 results, | ||
// so it cannot use these patterns. | ||
multiclass IMAD32_Pats <VOP3_Pseudo inst> { | ||
def : GCNPat < | ||
(ThreeOpFrag<mul, add> i32:$src0, i32:$src1, i32:$src2), | ||
(EXTRACT_SUBREG (inst $src0, $src1, | ||
(EXTRACT_SUBREG (inst i32:$src0, i32:$src1, | ||
(REG_SEQUENCE SReg_64, // Use scalar and let it be legalized | ||
$src2, sub0, | ||
(i32 (IMPLICIT_DEF)), sub1), | ||
0 /* clamp */), | ||
sub0) | ||
>; | ||
|
||
// GISel-specific pattern that avoids creating a SGPR->VGPR copy if | ||
// $src2 is a VGPR. | ||
def : GCNPat < | ||
(ThreeOpFrag<mul, add> i32:$src0, i32:$src1, VGPR_32:$src2), | ||
(EXTRACT_SUBREG (inst i32:$src0, i32:$src1, | ||
(REG_SEQUENCE VReg_64, | ||
$src2, sub0, | ||
(i32 (IMPLICIT_DEF)), sub1), | ||
0 /* clamp */), | ||
sub0) | ||
>; | ||
Comment on lines
+746
to
+752
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 we reduce duplication with OutFrags or something? 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. I didn't find a worthwhile way to do it, we save 2 lines in each pattern but add like 3-4 lines to declare the fragment so it's more or less the same |
||
|
||
// Immediate src2 in the pattern above will not fold because it would be partially | ||
// undef. Hence define specialized pattern for this case. | ||
// FIXME: GlobalISel pattern exporter fails to export a pattern like this and asserts, | ||
// make it SDAG only. | ||
def : GCNPat < | ||
(ThreeOpFragSDAG<mul, add> i32:$src0, i32:$src1, (i32 imm:$src2)), | ||
(EXTRACT_SUBREG (inst $src0, $src1, (i64 (as_i64imm $src2)), 0 /* clamp */), sub0) | ||
(ThreeOpFrag<mul, add> i32:$src0, i32:$src1, (i32 imm:$src2)), | ||
(EXTRACT_SUBREG (inst i32:$src0, i32:$src1, (i64 (as_i64imm $src2)), 0 /* clamp */), sub0) | ||
>; | ||
} | ||
|
||
|
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.
Can't we just add the VGPR_32 decoration to the original pattern?
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.
Doesn't seem to work, we need two patterns