Index: llvm/lib/Target/AMDGPU/SIInstrInfo.td =================================================================== --- llvm/lib/Target/AMDGPU/SIInstrInfo.td +++ llvm/lib/Target/AMDGPU/SIInstrInfo.td @@ -2042,11 +2042,6 @@ field bit HasSrc1 = !ne(Src1VT.Value, untyped.Value); field bit HasSrc2 = !ne(Src2VT.Value, untyped.Value); - // TODO: Modifiers logic is somewhat adhoc here, to be refined later - // HasModifiers affects the normal and DPP encodings. We take note of EnableF32SrcMods, which - // enables modifiers for i32 type. - field bit HasModifiers = !or(isModifierType.ret, EnableF32SrcMods); - // HasSrc*FloatMods affects the SDWA encoding. We ignore EnableF32SrcMods. field bit HasSrc0FloatMods = isFloatType.ret; field bit HasSrc1FloatMods = isFloatType.ret; @@ -2057,10 +2052,6 @@ field bit HasSrc1IntMods = isIntType.ret; field bit HasSrc2IntMods = isIntType.ret; - field bit HasSrc0Mods = HasModifiers; - field bit HasSrc1Mods = !if(HasModifiers, !or(HasSrc1FloatMods, HasSrc1IntMods), 0); - field bit HasSrc2Mods = !if(HasModifiers, !or(HasSrc2FloatMods, HasSrc2IntMods), 0); - field bit HasClamp = !or(isModifierType.ret, EnableClamp); field bit HasSDWAClamp = EmitDst; field bit HasFPClamp = !and(isFloatType.ret, HasClamp); @@ -2074,6 +2065,16 @@ field bit HasOMod = !if(HasOpSel, 0, isFloatType.ret); field bit HasSDWAOMod = isFloatType.ret; + field bit HasModifiers = !or(isModifierType.ret, + isModifierType.ret, + isModifierType.ret, + HasOMod, + EnableF32SrcMods); + + field bit HasSrc0Mods = HasModifiers; + field bit HasSrc1Mods = !if(HasModifiers, !or(HasSrc1FloatMods, HasSrc1IntMods), 0); + field bit HasSrc2Mods = !if(HasModifiers, !or(HasSrc2FloatMods, HasSrc2IntMods), 0); + field bit HasExt = getHasExt.ret; field bit HasExtDPP = getHasDPP.ret; field bit HasExtSDWA = HasExt; Index: llvm/lib/Target/AMDGPU/VOP1Instructions.td =================================================================== --- llvm/lib/Target/AMDGPU/VOP1Instructions.td +++ llvm/lib/Target/AMDGPU/VOP1Instructions.td @@ -91,14 +91,12 @@ } class getVOP1Pat64 : LetDummies { - list ret = + list ret = !if(P.HasModifiers, + !if(P.HasSrc0Mods, [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3Mods P.Src0VT:$src0, i32:$src0_modifiers))))], - !if(P.HasOMod, - [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3OMods P.Src0VT:$src0, - i1:$clamp, i32:$omod))))], - [(set P.DstVT:$vdst, (node P.Src0VT:$src0))] - ) + [(set P.DstVT:$vdst, (node (P.Src0VT (VOP3OMods P.Src0VT:$src0, i1:$clamp, i32:$omod))))]), + [(set P.DstVT:$vdst, (node P.Src0VT:$src0))] ); } @@ -136,9 +134,8 @@ let Ins64 = (ins Src0RC64:$src0, clampmod:$clamp, omod:$omod); let Asm64 = "$vdst, $src0$clamp$omod"; - let HasModifiers = 0; + let HasSrc0Mods = 0; let HasClamp = 1; - let HasOMod = 1; } def VOP1_F64_I32 : VOPProfileI2F ; Index: llvm/lib/Target/AMDGPU/VOP2Instructions.td =================================================================== --- llvm/lib/Target/AMDGPU/VOP2Instructions.td +++ llvm/lib/Target/AMDGPU/VOP2Instructions.td @@ -339,7 +339,6 @@ class VOP_DOT_ACC : VOP_MAC { let HasClamp = 0; let HasExtSDWA = 0; - let HasModifiers = 1; let HasOpSel = 0; let IsPacked = 0; } Index: llvm/lib/Target/AMDGPU/VOP3Instructions.td =================================================================== --- llvm/lib/Target/AMDGPU/VOP3Instructions.td +++ llvm/lib/Target/AMDGPU/VOP3Instructions.td @@ -183,7 +183,7 @@ let IsMAI = !if(Features.IsMAI, 1, P.IsMAI); let IsPacked = !if(Features.IsPacked, 1, P.IsPacked); - let HasModifiers = !if(Features.IsPacked, !not(Features.IsMAI), P.HasModifiers); + let HasModifiers = !if(Features.IsMAI, 0, !or(Features.IsPacked, P.HasModifiers)); // FIXME: Hack to stop printing _e64 let Outs64 = (outs DstRC.RegClass:$vdst); @@ -253,6 +253,7 @@ let Asm64 = "$vdst, $src0, $attr$attrchan$clamp$omod"; let HasClamp = 1; + let HasSrc0Mods = 0; } class getInterp16Asm { @@ -691,7 +692,6 @@ IntOpSelMods:$src2_modifiers, SCSrc_b32:$src2, VGPR_32:$vdst_in, op_sel0:$op_sel); let HasClamp = 0; - let HasOMod = 0; } class PermlanePat