@@ -262,12 +262,6 @@ class SPIRVInstructionSelector : public InstructionSelector {
262262 bool selectSaturate (Register ResVReg, const SPIRVType *ResType,
263263 MachineInstr &I) const ;
264264
265- bool selectSpvThreadId (Register ResVReg, const SPIRVType *ResType,
266- MachineInstr &I) const ;
267-
268- bool selectSpvGroupThreadId (Register ResVReg, const SPIRVType *ResType,
269- MachineInstr &I) const ;
270-
271265 bool selectWaveOpInst (Register ResVReg, const SPIRVType *ResType,
272266 MachineInstr &I, unsigned Opcode) const ;
273267
@@ -2831,9 +2825,21 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
28312825 return BuildCOPY (ResVReg, I.getOperand (2 ).getReg (), I);
28322826 break ;
28332827 case Intrinsic::spv_thread_id:
2834- return selectSpvThreadId (ResVReg, ResType, I);
2828+ // The HLSL SV_DispatchThreadID semantic is lowered to llvm.spv.thread.id
2829+ // intrinsic in LLVM IR for SPIR-V backend.
2830+ //
2831+ // In SPIR-V backend, llvm.spv.thread.id is now correctly translated to a
2832+ // `GlobalInvocationId` builtin variable
2833+ return loadVec3BuiltinInputID (SPIRV::BuiltIn::GlobalInvocationId, ResVReg,
2834+ ResType, I);
28352835 case Intrinsic::spv_thread_id_in_group:
2836- return selectSpvGroupThreadId (ResVReg, ResType, I);
2836+ // The HLSL SV_GroupThreadId semantic is lowered to
2837+ // llvm.spv.thread.id.in.group intrinsic in LLVM IR for SPIR-V backend.
2838+ //
2839+ // In SPIR-V backend, llvm.spv.thread.id.in.group is now correctly
2840+ // translated to a `LocalInvocationId` builtin variable
2841+ return loadVec3BuiltinInputID (SPIRV::BuiltIn::LocalInvocationId, ResVReg,
2842+ ResType, I);
28372843 case Intrinsic::spv_fdot:
28382844 return selectFloatDot (ResVReg, ResType, I);
28392845 case Intrinsic::spv_udot:
@@ -3535,7 +3541,7 @@ bool SPIRVInstructionSelector::selectLog10(Register ResVReg,
35353541
35363542// Generate the instructions to load 3-element vector builtin input
35373543// IDs/Indices.
3538- // Like: SV_DispatchThreadID, SV_GroupThreadID , etc....
3544+ // Like: GlobalInvocationId, LocalInvocationId , etc....
35393545bool SPIRVInstructionSelector::loadVec3BuiltinInputID (
35403546 SPIRV::BuiltIn::BuiltIn BuiltInValue, Register ResVReg,
35413547 const SPIRVType *ResType, MachineInstr &I) const {
@@ -3587,32 +3593,6 @@ bool SPIRVInstructionSelector::loadVec3BuiltinInputID(
35873593 return Result && MIB.constrainAllUses (TII, TRI, RBI);
35883594}
35893595
3590- bool SPIRVInstructionSelector::selectSpvThreadId (Register ResVReg,
3591- const SPIRVType *ResType,
3592- MachineInstr &I) const {
3593- // DX intrinsic: @llvm.dx.thread.id(i32)
3594- // ID Name Description
3595- // 93 ThreadId reads the thread ID
3596- //
3597- // In SPIR-V, llvm.dx.thread.id maps to a `GlobalInvocationId` builtin
3598- // variable
3599- return loadVec3BuiltinInputID (SPIRV::BuiltIn::GlobalInvocationId, ResVReg,
3600- ResType, I);
3601- }
3602-
3603- bool SPIRVInstructionSelector::selectSpvGroupThreadId (Register ResVReg,
3604- const SPIRVType *ResType,
3605- MachineInstr &I) const {
3606- // DX intrinsic: @llvm.dx.thread.id.in.group(i32)
3607- // ID Name Description
3608- // 95 GroupThreadId Reads the thread ID within the group
3609- //
3610- // In SPIR-V, llvm.dx.thread.id.in.group maps to a `LocalInvocationId` builtin
3611- // variable
3612- return loadVec3BuiltinInputID (SPIRV::BuiltIn::LocalInvocationId, ResVReg,
3613- ResType, I);
3614- }
3615-
36163596SPIRVType *SPIRVInstructionSelector::widenTypeToVec4 (const SPIRVType *Type,
36173597 MachineInstr &I) const {
36183598 MachineIRBuilder MIRBuilder (I);
0 commit comments