Skip to content

Commit ee78e03

Browse files
authored
AMDGPU: Avoid instantiating PatFrag with null_frag (llvm#77271)
This makes it possible to pass null_frag to the MAIInst multiclass. null_frag does not work as you may hope if used as the input to a PatFrag, which is what happens when it's passed through to *MAIFrag. Avoid this by checking for null_frag. It might be possible to hack up tablegen to allow consuming PatFrag inputs.
1 parent abaa79b commit ee78e03

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Target/AMDGPU/VOP3PInstructions.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,25 +623,26 @@ multiclass MAIInst<string OpName, string P, SDPatternOperator node,
623623
// FP32 denorm mode is respected, rounding mode is not. Exceptions are not supported.
624624
let Constraints = !if(NoDstOverlap, "@earlyclobber $vdst", "") in {
625625
def _e64 : MAIInst<OpName, !cast<VOPProfileMAI>("VOPProfileMAI_" # P),
626-
!if(NoDstOverlap, null_frag, AgprMAIFrag<node>)>,
626+
!if(!or(NoDstOverlap, !eq(node, null_frag)), null_frag, AgprMAIFrag<node>)>,
627627
MFMATable<0, NAME # "_e64">;
628628

629629
let SubtargetPredicate = isGFX90APlus, Mnemonic = OpName in
630630
def _vgprcd_e64 : MAIInst<OpName # "_vgprcd", !cast<VOPProfileMAI>("VOPProfileMAI_" # P # "_VCD"),
631-
!if(NoDstOverlap, null_frag, VgprMAIFrag<node>)>,
631+
!if(!or(NoDstOverlap, !eq(node, null_frag)), null_frag, VgprMAIFrag<node>)>,
632632
MFMATable<0, NAME # "_vgprcd_e64">;
633633
}
634634

635635
if NoDstOverlap then {
636636
let Constraints = !if(NoDstOverlap, "$vdst = $src2", ""),
637637
isConvertibleToThreeAddress = NoDstOverlap,
638638
Mnemonic = OpName in {
639-
def "_mac_e64" : MAIInst<OpName # "_mac", !cast<VOPProfileMAI>("VOPProfileMAI_" # P), AgprMAIFrag<node>>,
639+
def "_mac_e64" : MAIInst<OpName # "_mac", !cast<VOPProfileMAI>("VOPProfileMAI_" # P),
640+
!if(!eq(node, null_frag), null_frag, AgprMAIFrag<node>)>,
640641
MFMATable<1, NAME # "_e64">;
641642

642643
let SubtargetPredicate = isGFX90APlus in
643644
def _mac_vgprcd_e64 : MAIInst<OpName # "_mac_vgprcd", !cast<VOPProfileMAI>("VOPProfileMAI_" # P # "_VCD"),
644-
VgprMAIFrag<node>>,
645+
!if(!eq(node, null_frag), null_frag, VgprMAIFrag<node>)>,
645646
MFMATable<1, NAME # "_vgprcd_e64">;
646647
}
647648
}

0 commit comments

Comments
 (0)