Skip to content

Commit fcef407

Browse files
authored
AMDGPU/NFC: Remove some bits from TSFlags (#81525)
- AMDGPU/NFC: Purge SOPK_ZEXT from TSFlags - Moved to helper function in SIInstInfo - AMDGPU/NFC: Purge VOPAsmPrefer32Bit from TSFlags - This flag did not make sense / remnants of something else I think
1 parent aef36eb commit fcef407

9 files changed

+26
-35
lines changed

Diff for: llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -3299,11 +3299,6 @@ unsigned AMDGPUAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
32993299
(isForcedSDWA() && !(TSFlags & SIInstrFlags::SDWA)) )
33003300
return Match_InvalidOperand;
33013301

3302-
if ((TSFlags & SIInstrFlags::VOP3) &&
3303-
(TSFlags & SIInstrFlags::VOPAsmPrefer32Bit) &&
3304-
getForcedEncodingSize() != 64)
3305-
return Match_PreferE32;
3306-
33073302
if (Inst.getOpcode() == AMDGPU::V_MAC_F32_sdwa_vi ||
33083303
Inst.getOpcode() == AMDGPU::V_MAC_F16_sdwa_vi) {
33093304
// v_mac_f32/16 allow only dst_sel == DWORD;

Diff for: llvm/lib/Target/AMDGPU/SIDefines.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,16 @@ enum : uint64_t {
105105
WQM = UINT64_C(1) << 35,
106106
DisableWQM = UINT64_C(1) << 36,
107107
Gather4 = UINT64_C(1) << 37,
108-
SOPK_ZEXT = UINT64_C(1) << 38,
108+
109+
// Reserved, must be 0.
110+
Reserved0 = UINT64_C(1) << 38,
111+
109112
SCALAR_STORE = UINT64_C(1) << 39,
110113
FIXED_SIZE = UINT64_C(1) << 40,
111-
VOPAsmPrefer32Bit = UINT64_C(1) << 41,
114+
115+
// Reserved, must be 0.
116+
Reserved1 = UINT64_C(1) << 41,
117+
112118
VOP3_OPSEL = UINT64_C(1) << 42,
113119
maybeAtomic = UINT64_C(1) << 43,
114120
renamedInGFX9 = UINT64_C(1) << 44,

Diff for: llvm/lib/Target/AMDGPU/SIInstrFormats.td

+7-10
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ class InstSI <dag outs, dag ins, string asm = "",
6969

7070
field bit Gather4 = 0;
7171

72-
// Most sopk treat the immediate as a signed 16-bit, however some
73-
// use it as unsigned.
74-
field bit SOPKZext = 0;
75-
7672
// This is an s_store_dword* instruction that requires a cache flush
7773
// on wave termination. It is necessary to distinguish from mayStore
7874
// SMEM instructions like the cache flush ones.
@@ -82,10 +78,6 @@ class InstSI <dag outs, dag ins, string asm = "",
8278
// instruction size.
8379
field bit FixedSize = 0;
8480

85-
// This bit tells the assembler to use the 32-bit encoding in case it
86-
// is unable to infer the encoding from the operands.
87-
field bit VOPAsmPrefer32Bit = 0;
88-
8981
// This bit indicates that this is a VOP3 opcode which supports op_sel
9082
// modifier.
9183
field bit VOP3_OPSEL = 0;
@@ -209,10 +201,15 @@ class InstSI <dag outs, dag ins, string asm = "",
209201
let TSFlags{36} = DisableWQM;
210202
let TSFlags{37} = Gather4;
211203

212-
let TSFlags{38} = SOPKZext;
204+
// Reserved, must be 0.
205+
let TSFlags{38} = 0;
206+
213207
let TSFlags{39} = ScalarStore;
214208
let TSFlags{40} = FixedSize;
215-
let TSFlags{41} = VOPAsmPrefer32Bit;
209+
210+
// Reserved, must be 0.
211+
let TSFlags{41} = 0;
212+
216213
let TSFlags{42} = VOP3_OPSEL;
217214

218215
let TSFlags{43} = maybeAtomic;

Diff for: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4918,7 +4918,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
49184918
}
49194919
} else {
49204920
uint64_t Imm = Op->getImm();
4921-
if (sopkIsZext(MI)) {
4921+
if (sopkIsZext(Opcode)) {
49224922
if (!isUInt<16>(Imm)) {
49234923
ErrInfo = "invalid immediate for SOPK instruction";
49244924
return false;

Diff for: llvm/lib/Target/AMDGPU/SIInstrInfo.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,13 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
842842
return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
843843
}
844844

845-
static bool sopkIsZext(const MachineInstr &MI) {
846-
return MI.getDesc().TSFlags & SIInstrFlags::SOPK_ZEXT;
847-
}
848-
849-
bool sopkIsZext(uint16_t Opcode) const {
850-
return get(Opcode).TSFlags & SIInstrFlags::SOPK_ZEXT;
845+
// Most sopk treat the immediate as a signed 16-bit, however some
846+
// use it as unsigned.
847+
static bool sopkIsZext(unsigned Opcode) {
848+
return Opcode == AMDGPU::S_CMPK_EQ_U32 || Opcode == AMDGPU::S_CMPK_LG_U32 ||
849+
Opcode == AMDGPU::S_CMPK_GT_U32 || Opcode == AMDGPU::S_CMPK_GE_U32 ||
850+
Opcode == AMDGPU::S_CMPK_LT_U32 || Opcode == AMDGPU::S_CMPK_LE_U32 ||
851+
Opcode == AMDGPU::S_GETREG_B32;
851852
}
852853

853854
/// \returns true if this is an s_store_dword* instruction. This is more

Diff for: llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ void SIShrinkInstructions::shrinkScalarCompare(MachineInstr &MI) const {
251251

252252
const MCInstrDesc &NewDesc = TII->get(SOPKOpc);
253253

254-
if ((TII->sopkIsZext(SOPKOpc) && isKUImmOperand(Src1)) ||
255-
(!TII->sopkIsZext(SOPKOpc) && isKImmOperand(Src1))) {
256-
if (!TII->sopkIsZext(SOPKOpc))
254+
if ((SIInstrInfo::sopkIsZext(SOPKOpc) && isKUImmOperand(Src1)) ||
255+
(!SIInstrInfo::sopkIsZext(SOPKOpc) && isKImmOperand(Src1))) {
256+
if (!SIInstrInfo::sopkIsZext(SOPKOpc))
257257
Src1.setImm(SignExtend64(Src1.getImm(), 32));
258258
MI.setDesc(NewDesc);
259259
}

Diff for: llvm/lib/Target/AMDGPU/SOPInstructions.td

-3
Original file line numberDiff line numberDiff line change
@@ -1078,14 +1078,12 @@ def S_CMPK_GE_I32 : SOPK_SCC <"s_cmpk_ge_i32", "s_cmp_ge_i32", 1>;
10781078
def S_CMPK_LT_I32 : SOPK_SCC <"s_cmpk_lt_i32", "s_cmp_lt_i32", 1>;
10791079
def S_CMPK_LE_I32 : SOPK_SCC <"s_cmpk_le_i32", "s_cmp_le_i32", 1>;
10801080

1081-
let SOPKZext = 1 in {
10821081
def S_CMPK_EQ_U32 : SOPK_SCC <"s_cmpk_eq_u32", "s_cmp_eq_u32", 0>;
10831082
def S_CMPK_LG_U32 : SOPK_SCC <"s_cmpk_lg_u32", "s_cmp_lg_u32", 0>;
10841083
def S_CMPK_GT_U32 : SOPK_SCC <"s_cmpk_gt_u32", "s_cmp_gt_u32", 0>;
10851084
def S_CMPK_GE_U32 : SOPK_SCC <"s_cmpk_ge_u32", "s_cmp_ge_u32", 0>;
10861085
def S_CMPK_LT_U32 : SOPK_SCC <"s_cmpk_lt_u32", "s_cmp_lt_u32", 0>;
10871086
def S_CMPK_LE_U32 : SOPK_SCC <"s_cmpk_le_u32", "s_cmp_le_u32", 0>;
1088-
} // End SOPKZext = 1
10891087
} // End isCompare = 1
10901088

10911089
let isCommutable = 1, DisableEncoding = "$src0",
@@ -1111,7 +1109,6 @@ def S_GETREG_B32 : SOPK_Pseudo <
11111109
(outs SReg_32:$sdst), (ins hwreg:$simm16),
11121110
"$sdst, $simm16",
11131111
[(set i32:$sdst, (int_amdgcn_s_getreg (i32 timm:$simm16)))]> {
1114-
let SOPKZext = 1;
11151112
let hasSideEffects = 1;
11161113
}
11171114

Diff for: llvm/lib/Target/AMDGPU/VOP1Instructions.td

-4
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ def VOP_I16_F16_SPECIAL_OMOD_t16 : VOPProfile_Fake16<VOP_I16_F16> {
217217
// VOP1 Instructions
218218
//===----------------------------------------------------------------------===//
219219

220-
let VOPAsmPrefer32Bit = 1 in {
221220
defm V_NOP : VOP1Inst <"v_nop", VOP_NOP_PROFILE>;
222-
}
223221

224222
def VOPProfile_MOV : VOPProfile <[i32, i32, untyped, untyped]> {
225223
let InsVOPDX = (ins Src0RC32:$src0X);
@@ -368,9 +366,7 @@ defm V_FREXP_EXP_I32_F32 : VOP1Inst <"v_frexp_exp_i32_f32", VOP_I32_F32, int_amd
368366
defm V_FREXP_MANT_F32 : VOP1Inst <"v_frexp_mant_f32", VOP_F32_F32, int_amdgcn_frexp_mant>;
369367
} // End isReMaterializable = 1
370368

371-
let VOPAsmPrefer32Bit = 1 in {
372369
defm V_CLREXCP : VOP1Inst <"v_clrexcp", VOP_NO_EXT<VOP_NONE>>;
373-
}
374370

375371
// Restrict src0 to be VGPR
376372
def VOP_MOVRELS : VOPProfile<[i32, i32, untyped, untyped]> {

Diff for: llvm/lib/Target/AMDGPU/VOPInstructions.td

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class LetDummies {
1616
bit isMoveImm;
1717
bit isReMaterializable;
1818
bit isAsCheapAsAMove;
19-
bit VOPAsmPrefer32Bit;
2019
bit FPDPRounding;
2120
Predicate SubtargetPredicate;
2221
string Constraints;

0 commit comments

Comments
 (0)