Skip to content

Commit 78f7e5d

Browse files
committed
self review:
- the execution scope must be the second operand and not the final operand of the SPIRV instruction. this was missed as I did not realize that SPIRV-TOOLS was not enabled on my local machine but luckily got caught by the spir-v github tests - missing testcase for int64 in directx lowering and caught that Int64Ty was missing from the overload types of dxilop
1 parent 8a75558 commit 78f7e5d

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,8 @@ def WaveReadLaneAt: DXILOp<117, waveReadLaneAt> {
807807
let LLVMIntrinsic = int_dx_wave_readlane;
808808
let arguments = [OverloadTy, Int32Ty];
809809
let result = OverloadTy;
810-
let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy, DoubleTy, Int1Ty, Int16Ty, Int32Ty]>];
811-
let stages = [Stages<DXIL1_0, [all_stages]>];
810+
let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy, DoubleTy, Int1Ty, Int16Ty, Int32Ty, Int64Ty]>];
811+
let stages = [Stages<DXIL1_0, [all_stages]>];
812812
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
813813
}
814814

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,9 +1777,9 @@ bool SPIRVInstructionSelector::selectWaveReadLaneAt(Register ResVReg,
17771777
TII.get(SPIRV::OpGroupNonUniformShuffle))
17781778
.addDef(ResVReg)
17791779
.addUse(GR.getSPIRVTypeID(ResType))
1780+
.addUse(GR.getOrCreateConstInt(3, I, IntTy, TII))
17801781
.addUse(I.getOperand(2).getReg())
1781-
.addUse(I.getOperand(3).getReg())
1782-
.addUse(GR.getOrCreateConstInt(3, I, IntTy, TII));
1782+
.addUse(I.getOperand(3).getReg());
17831783
}
17841784

17851785
bool SPIRVInstructionSelector::selectBitreverse(Register ResVReg,

llvm/test/CodeGen/DirectX/WaveReadLaneAt.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,18 @@ entry:
4444
ret i32 %ret
4545
}
4646

47+
define noundef i64 @wave_rla_i64(i64 noundef %expr, i32 noundef %idx) {
48+
entry:
49+
; CHECK: call i64 @dx.op.waveReadLaneAt.i64(i32 117, i64 %expr, i32 %idx)
50+
%ret = call i64 @llvm.dx.wave.readlane.i64(i64 %expr, i32 %idx)
51+
ret i64 %ret
52+
}
53+
4754
declare half @llvm.dx.wave.readlane.f16(half, i32)
4855
declare float @llvm.dx.wave.readlane.f32(float, i32)
4956
declare double @llvm.dx.wave.readlane.f64(double, i32)
5057

5158
declare i1 @llvm.dx.wave.readlane.i1(i1, i32)
5259
declare i16 @llvm.dx.wave.readlane.i16(i16, i32)
5360
declare i32 @llvm.dx.wave.readlane.i32(i32, i32)
61+
declare i64 @llvm.dx.wave.readlane.i64(i64, i32)

llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - | FileCheck %s
2-
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-unknown %s -o - -filetype=obj | spirv-val %}
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-vulkan-unknown %s -o - -filetype=obj | spirv-val %}
33

44
; Test lowering to spir-v backend for various types and scalar/vector
55

@@ -9,29 +9,32 @@
99
; CHECK-DAG: %[[#v4_bool:]] = OpTypeVector %[[#bool]] 4
1010
; CHECK-DAG: %[[#scope:]] = OpConstant %[[#uint]] 3
1111

12+
; CHECK-LABEL: Begin function test_float
1213
; CHECK: %[[#fexpr:]] = OpFunctionParameter %[[#f32]]
1314
; CHECK: %[[#idx1:]] = OpFunctionParameter %[[#uint]]
14-
define float @test_1(float %fexpr, i32 %idx) {
15+
define float @test_float(float %fexpr, i32 %idx) {
1516
entry:
16-
; CHECK: %[[#fret:]] = OpGroupNonUniformShuffle %[[#f32]] %[[#fexpr]] %[[#idx1]] %[[#scope]]
17+
; CHECK: %[[#fret:]] = OpGroupNonUniformShuffle %[[#f32]] %[[#scope]] %[[#fexpr]] %[[#idx1]]
1718
%0 = call float @llvm.spv.wave.readlane.f32(float %fexpr, i32 %idx)
1819
ret float %0
1920
}
2021

22+
; CHECK-LABEL: Begin function test_int
2123
; CHECK: %[[#iexpr:]] = OpFunctionParameter %[[#uint]]
2224
; CHECK: %[[#idx2:]] = OpFunctionParameter %[[#uint]]
23-
define i32 @test_2(i32 %iexpr, i32 %idx) {
25+
define i32 @test_int(i32 %iexpr, i32 %idx) {
2426
entry:
25-
; CHECK: %[[#iret:]] = OpGroupNonUniformShuffle %[[#uint]] %[[#iexpr]] %[[#idx2]] %[[#scope]]
27+
; CHECK: %[[#iret:]] = OpGroupNonUniformShuffle %[[#uint]] %[[#scope]] %[[#iexpr]] %[[#idx2]]
2628
%0 = call i32 @llvm.spv.wave.readlane.i32(i32 %iexpr, i32 %idx)
2729
ret i32 %0
2830
}
2931

32+
; CHECK-LABEL: Begin function test_vbool
3033
; CHECK: %[[#vbexpr:]] = OpFunctionParameter %[[#v4_bool]]
3134
; CHECK: %[[#idx3:]] = OpFunctionParameter %[[#uint]]
32-
define <4 x i1> @test_3(<4 x i1> %vbexpr, i32 %idx) {
35+
define <4 x i1> @test_vbool(<4 x i1> %vbexpr, i32 %idx) {
3336
entry:
34-
; CHECK: %[[#vbret:]] = OpGroupNonUniformShuffle %[[#v4_bool]] %[[#vbexpr]] %[[#idx3]] %[[#scope]]
37+
; CHECK: %[[#vbret:]] = OpGroupNonUniformShuffle %[[#v4_bool]] %[[#scope]] %[[#vbexpr]] %[[#idx3]]
3538
%0 = call <4 x i1> @llvm.spv.wave.readlane.v4i1(<4 x i1> %vbexpr, i32 %idx)
3639
ret <4 x i1> %0
3740
}

0 commit comments

Comments
 (0)