Skip to content

Commit 906f105

Browse files
committed
self review:
- add support for selecting a non-side effect convergent intrinsic - update test case to not be optimized away
1 parent 32f1015 commit 906f105

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ bool SPIRVInstructionSelector::spvSelect(Register ResVReg,
431431

432432
case TargetOpcode::G_INTRINSIC:
433433
case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
434+
case TargetOpcode::G_INTRINSIC_CONVERGENT:
434435
case TargetOpcode::G_INTRINSIC_CONVERGENT_W_SIDE_EFFECTS:
435436
return selectIntrinsic(ResVReg, ResType, I);
436437
case TargetOpcode::G_BITREVERSE:

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

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

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

6-
; CHECK-DAG: %[[#uint:]] = OpTypeInt 32 0
7-
; CHECK-DAG: %[[#scope:]] = OpConstant %[[#uint]] 3
86
; CHECK-DAG: %[[#f32:]] = OpTypeFloat 32
7+
; CHECK-DAG: %[[#uint:]] = OpTypeInt 32 0
98
; CHECK-DAG: %[[#bool:]] = OpTypeBool
109
; CHECK-DAG: %[[#v4_bool:]] = OpTypeVector %[[#bool]] 4
11-
; CHECK-DAG: %[[#fexpr:]] = OpFunctionParameter %[[#f32]]
12-
; CHECK-DAG: %[[#iexpr:]] = OpFunctionParameter %[[#uint]]
13-
; CHECK-DAG: %[[#idx:]] = OpFunctionParameter %[[#uint]]
14-
; CHECK-DAG: %[[#vbexpr:]] = OpFunctionParameter %[[#v4_bool]]
10+
; CHECK-DAG: %[[#scope:]] = OpConstant %[[#uint]] 3
1511

16-
define spir_func void @test_1(float %fexpr, i32 %iexpr, <4 x i1> %vbexpr, i32 %idx) {
12+
; CHECK: %[[#fexpr:]] = OpFunctionParameter %[[#f32]]
13+
; CHECK: %[[#idx1:]] = OpFunctionParameter %[[#uint]]
14+
define float @test_1(float %fexpr, i32 %idx) {
1715
entry:
18-
; CHECK: %[[#fret:]] = OpGroupNonUniformShuffle %[[#f32]] %[[#fexpr]] %[[#idx]] %[[#scope]]
16+
; CHECK: %[[#fret:]] = OpGroupNonUniformShuffle %[[#f32]] %[[#fexpr]] %[[#idx1]] %[[#scope]]
1917
%0 = call float @llvm.spv.waveReadLaneAt.f32(float %fexpr, i32 %idx)
20-
; CHECK: %[[#iret:]] = OpGroupNonUniformShuffle %[[#uint]] %[[#iexpr]] %[[#idx]] %[[#scope]]
21-
%1 = call i32 @llvm.spv.waveReadLaneAt.i32(i32 %iexpr, i32 %idx)
22-
; CHECK: %[[#vbret:]] = OpGroupNonUniformShuffle %[[#v4_bool]] %[[#vbexpr]] %[[#idx]] %[[#scope]]
23-
%2 = call <4 x i1> @llvm.spv.waveReadLaneAt.v4i1(<4 x i1> %vbexpr, i32 %idx)
24-
ret void
18+
ret float %0
19+
}
20+
21+
; CHECK: %[[#iexpr:]] = OpFunctionParameter %[[#uint]]
22+
; CHECK: %[[#idx2:]] = OpFunctionParameter %[[#uint]]
23+
define i32 @test_2(i32 %iexpr, i32 %idx) {
24+
entry:
25+
; CHECK: %[[#iret:]] = OpGroupNonUniformShuffle %[[#uint]] %[[#iexpr]] %[[#idx2]] %[[#scope]]
26+
%0 = call i32 @llvm.spv.waveReadLaneAt.i32(i32 %iexpr, i32 %idx)
27+
ret i32 %0
28+
}
29+
30+
; CHECK: %[[#vbexpr:]] = OpFunctionParameter %[[#v4_bool]]
31+
; CHECK: %[[#idx3:]] = OpFunctionParameter %[[#uint]]
32+
define <4 x i1> @test_3(<4 x i1> %vbexpr, i32 %idx) {
33+
entry:
34+
; CHECK: %[[#vbret:]] = OpGroupNonUniformShuffle %[[#v4_bool]] %[[#vbexpr]] %[[#idx3]] %[[#scope]]
35+
%0 = call <4 x i1> @llvm.spv.waveReadLaneAt.v4i1(<4 x i1> %vbexpr, i32 %idx)
36+
ret <4 x i1> %0
2537
}
2638

2739
declare float @llvm.spv.waveReadLaneAt.f32(float, i32)

0 commit comments

Comments
 (0)