Index: llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -233,7 +233,7 @@ template bool SelectFlatOffset(SDNode *N, SDValue Addr, SDValue &VAddr, - SDValue &Offset, SDValue &SLC) const; + SDValue &Offset) const; bool SelectSMRDOffset(SDValue ByteOffsetNode, SDValue &Offset, bool &Imm) const; @@ -1658,8 +1658,7 @@ bool AMDGPUDAGToDAGISel::SelectFlatOffset(SDNode *N, SDValue Addr, SDValue &VAddr, - SDValue &Offset, - SDValue &SLC) const { + SDValue &Offset) const { int64_t OffsetVal = 0; if (Subtarget->hasFlatInstOffsets() && @@ -1748,7 +1747,6 @@ VAddr = Addr; Offset = CurDAG->getTargetConstant(OffsetVal, SDLoc(), MVT::i16); - SLC = CurDAG->getTargetConstant(0, SDLoc(), MVT::i1); return true; } Index: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -3218,7 +3218,6 @@ InstructionSelector::ComplexRendererFns Default = {{ [=](MachineInstrBuilder &MIB) { MIB.addReg(Root.getReg()); }, [=](MachineInstrBuilder &MIB) { MIB.addImm(0); }, // offset - [=](MachineInstrBuilder &MIB) { MIB.addImm(0); } // slc }}; if (!STI.hasFlatInstOffsets()) @@ -3242,7 +3241,6 @@ return {{ [=](MachineInstrBuilder &MIB) { MIB.addReg(BasePtr); }, [=](MachineInstrBuilder &MIB) { MIB.addImm(Offset.getValue()); }, - [=](MachineInstrBuilder &MIB) { MIB.addImm(0); } // slc }}; } Index: llvm/lib/Target/AMDGPU/FLATInstructions.td =================================================================== --- llvm/lib/Target/AMDGPU/FLATInstructions.td +++ llvm/lib/Target/AMDGPU/FLATInstructions.td @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -def FLATOffset : ComplexPattern", [], [SDNPWantRoot], -10>; -def FLATOffsetSigned : ComplexPattern", [], [SDNPWantRoot], -10>; +def FLATOffset : ComplexPattern", [], [SDNPWantRoot], -10>; +def FLATOffsetSigned : ComplexPattern", [], [SDNPWantRoot], -10>; //===----------------------------------------------------------------------===// // FLAT classes @@ -140,8 +140,10 @@ !if(EnableSaddr, (ins SReg_64:$saddr, VGPR_32:$vaddr), (ins VReg_64:$vaddr)), - (ins flat_offset:$offset, GLC:$glc, SLC:$slc, DLC:$dlc)), - !if(HasTiedOutput, (ins regClass:$vdst_in), (ins))), + (ins flat_offset:$offset)), + // FIXME: Operands with default values do not work with following non-optional operands. + !if(HasTiedOutput, (ins GLC:$glc, SLC:$slc, DLC:$dlc, regClass:$vdst_in), + (ins GLC_0:$glc, SLC_0:$slc, DLC_0:$dlc))), " $vdst, $vaddr"#!if(HasSaddr, !if(EnableSaddr, ", $saddr", ", off"), "")#"$offset$glc$slc$dlc"> { let has_data = 0; let mayLoad = 1; @@ -162,7 +164,7 @@ !if(EnableSaddr, (ins VGPR_32:$vaddr, vdataClass:$vdata, SReg_64:$saddr), (ins VReg_64:$vaddr, vdataClass:$vdata)), - (ins flat_offset:$offset, GLC:$glc, SLC:$slc, DLC:$dlc)), + (ins flat_offset:$offset, GLC_0:$glc, SLC_0:$slc, DLC_0:$dlc)), " $vaddr, $vdata"#!if(HasSaddr, !if(EnableSaddr, ", $saddr", ", off"), "")#"$offset$glc$slc$dlc"> { let mayLoad = 0; let mayStore = 1; @@ -186,7 +188,7 @@ bit HasTiedOutput = 0, bit HasSignedOffset = 0> : FLAT_Pseudo< opName, (outs regClass:$vdst), - !con((ins SReg_64:$saddr, flat_offset:$offset, GLC:$glc, SLC:$slc, DLC:$dlc), + !con((ins SReg_64:$saddr, flat_offset:$offset, GLC_0:$glc, SLC_0:$slc, DLC_0:$dlc), !if(HasTiedOutput, (ins regClass:$vdst_in), (ins))), " $vdst, $saddr$offset$glc$slc$dlc"> { let is_flat_global = 1; @@ -309,7 +311,7 @@ bit isFP = isFloatType.ret> { def "" : FLAT_AtomicNoRet_Pseudo , GlobalSaddrTable<0, opName>, AtomicNoRet { @@ -320,10 +322,10 @@ def _RTN : FLAT_AtomicRet_Pseudo , + (atomic (FLATOffset i64:$vaddr, i16:$offset), data_vt:$vdata))]>, GlobalSaddrTable<0, opName#"_rtn">, AtomicNoRet { let FPAtomic = isFP; @@ -342,7 +344,7 @@ def "" : FLAT_AtomicNoRet_Pseudo , GlobalSaddrTable<0, opName>, AtomicNoRet { @@ -353,7 +355,7 @@ def _SADDR : FLAT_AtomicNoRet_Pseudo , GlobalSaddrTable<1, opName>, AtomicNoRet { @@ -375,10 +377,10 @@ def _RTN : FLAT_AtomicRet_Pseudo , + (atomic (FLATOffsetSigned i64:$vaddr, i16:$offset), data_vt:$vdata))]>, GlobalSaddrTable<0, opName#"_rtn">, AtomicNoRet { let has_saddr = 1; @@ -387,7 +389,7 @@ def _SADDR_RTN : FLAT_AtomicRet_Pseudo , GlobalSaddrTable<1, opName#"_rtn">, AtomicNoRet { @@ -727,64 +729,64 @@ // Patterns for global loads with no offset. class FlatLoadPat : GCNPat < - (vt (node (FLATOffset i64:$vaddr, i16:$offset, i1:$slc))), - (inst $vaddr, $offset, 0, 0, $slc) + (vt (node (FLATOffset i64:$vaddr, i16:$offset))), + (inst $vaddr, $offset) >; class FlatLoadPat_D16 : GCNPat < - (node (FLATOffset (i64 VReg_64:$vaddr), i16:$offset, i1:$slc), vt:$in), - (inst $vaddr, $offset, 0, 0, $slc, $in) + (node (FLATOffset (i64 VReg_64:$vaddr), i16:$offset), vt:$in), + (inst $vaddr, $offset, 0, 0, 0, $in) >; class FlatSignedLoadPat_D16 : GCNPat < - (node (FLATOffsetSigned (i64 VReg_64:$vaddr), i16:$offset, i1:$slc), vt:$in), - (inst $vaddr, $offset, 0, 0, $slc, $in) + (node (FLATOffsetSigned (i64 VReg_64:$vaddr), i16:$offset), vt:$in), + (inst $vaddr, $offset, 0, 0, 0, $in) >; class FlatLoadSignedPat : GCNPat < - (vt (node (FLATOffsetSigned (i64 VReg_64:$vaddr), i16:$offset, i1:$slc))), - (inst $vaddr, $offset, 0, 0, $slc) + (vt (node (FLATOffsetSigned (i64 VReg_64:$vaddr), i16:$offset))), + (inst $vaddr, $offset) >; class FlatStorePat : GCNPat < - (node vt:$data, (FLATOffset i64:$vaddr, i16:$offset, i1:$slc)), - (inst $vaddr, rc:$data, $offset, 0, 0, $slc) + (node vt:$data, (FLATOffset i64:$vaddr, i16:$offset)), + (inst $vaddr, rc:$data, $offset) >; class FlatStoreSignedPat : GCNPat < - (node vt:$data, (FLATOffsetSigned i64:$vaddr, i16:$offset, i1:$slc)), - (inst $vaddr, rc:$data, $offset, 0, 0, $slc) + (node vt:$data, (FLATOffsetSigned i64:$vaddr, i16:$offset)), + (inst $vaddr, rc:$data, $offset) >; class FlatStoreAtomicPat : GCNPat < // atomic store follows atomic binop convention so the address comes // first. - (node (FLATOffset i64:$vaddr, i16:$offset, i1:$slc), vt:$data), - (inst $vaddr, rc:$data, $offset, 0, 0, $slc) + (node (FLATOffset i64:$vaddr, i16:$offset), vt:$data), + (inst $vaddr, rc:$data, $offset) >; class FlatStoreSignedAtomicPat : GCNPat < // atomic store follows atomic binop convention so the address comes // first. - (node (FLATOffset i64:$vaddr, i16:$offset, i1:$slc), vt:$data), - (inst $vaddr, rc:$data, $offset, 0, 0, $slc) + (node (FLATOffset i64:$vaddr, i16:$offset), vt:$data), + (inst $vaddr, rc:$data, $offset) >; class FlatAtomicPat : GCNPat < - (vt (node (FLATOffset i64:$vaddr, i16:$offset, i1:$slc), data_vt:$data)), - (inst $vaddr, $data, $offset, $slc) + (vt (node (FLATOffset i64:$vaddr, i16:$offset), data_vt:$data)), + (inst $vaddr, $data, $offset) >; class FlatAtomicPatNoRtn : GCNPat < - (node (FLATOffset i64:$vaddr, i16:$offset, i1:$slc), vt:$data), - (inst VReg_64:$vaddr, getVregSrcForVT.ret:$data, $offset, $slc) + (node (FLATOffset i64:$vaddr, i16:$offset), vt:$data), + (inst VReg_64:$vaddr, getVregSrcForVT.ret:$data, $offset) >; class FlatSignedAtomicPat : GCNPat < - (vt (node (FLATOffsetSigned i64:$vaddr, i16:$offset, i1:$slc), data_vt:$data)), - (inst $vaddr, $data, $offset, $slc) + (vt (node (FLATOffsetSigned i64:$vaddr, i16:$offset), data_vt:$data)), + (inst $vaddr, $data, $offset) >; let OtherPredicates = [HasFlatAddressSpace] in { Index: llvm/lib/Target/AMDGPU/SIInstrInfo.td =================================================================== --- llvm/lib/Target/AMDGPU/SIInstrInfo.td +++ llvm/lib/Target/AMDGPU/SIInstrInfo.td @@ -1084,8 +1084,14 @@ def highmod : NamedOperandBit<"High", NamedMatchClass<"High">>; def DLC : NamedOperandBit<"DLC", NamedMatchClass<"DLC">>; +def DLC_0 : NamedOperandBit_0<"DLC", NamedMatchClass<"DLC">>; + def GLC : NamedOperandBit<"GLC", NamedMatchClass<"GLC">>; +def GLC_0 : NamedOperandBit_0<"GLC", NamedMatchClass<"GLC">>; + def SLC : NamedOperandBit<"SLC", NamedMatchClass<"SLC">>; +def SLC_0 : NamedOperandBit_0<"SLC", NamedMatchClass<"SLC">>; + def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>; def SWZ : NamedOperandBit<"SWZ", NamedMatchClass<"SWZ">>; def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>;