@@ -262,12 +262,6 @@ class SPIRVInstructionSelector : public InstructionSelector {
262
262
bool selectSaturate (Register ResVReg, const SPIRVType *ResType,
263
263
MachineInstr &I) const ;
264
264
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
-
271
265
bool selectWaveOpInst (Register ResVReg, const SPIRVType *ResType,
272
266
MachineInstr &I, unsigned Opcode) const ;
273
267
@@ -2831,9 +2825,21 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg,
2831
2825
return BuildCOPY (ResVReg, I.getOperand (2 ).getReg (), I);
2832
2826
break ;
2833
2827
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);
2835
2835
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);
2837
2843
case Intrinsic::spv_fdot:
2838
2844
return selectFloatDot (ResVReg, ResType, I);
2839
2845
case Intrinsic::spv_udot:
@@ -3535,7 +3541,7 @@ bool SPIRVInstructionSelector::selectLog10(Register ResVReg,
3535
3541
3536
3542
// Generate the instructions to load 3-element vector builtin input
3537
3543
// IDs/Indices.
3538
- // Like: SV_DispatchThreadID, SV_GroupThreadID , etc....
3544
+ // Like: GlobalInvocationId, LocalInvocationId , etc....
3539
3545
bool SPIRVInstructionSelector::loadVec3BuiltinInputID (
3540
3546
SPIRV::BuiltIn::BuiltIn BuiltInValue, Register ResVReg,
3541
3547
const SPIRVType *ResType, MachineInstr &I) const {
@@ -3587,32 +3593,6 @@ bool SPIRVInstructionSelector::loadVec3BuiltinInputID(
3587
3593
return Result && MIB.constrainAllUses (TII, TRI, RBI);
3588
3594
}
3589
3595
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
-
3616
3596
SPIRVType *SPIRVInstructionSelector::widenTypeToVec4 (const SPIRVType *Type,
3617
3597
MachineInstr &I) const {
3618
3598
MachineIRBuilder MIRBuilder (I);
0 commit comments