Debian Codegraph @

llvm/test/CodeGen/SPIRV/extensions/SPV_KHR_float_controls2/exec_mode3.ll

raw
1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_float_controls2 %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_float_controls2 %s -o - -filetype=obj | spirv-val %}
3
4 ; CHECK-DAG: Capability FloatControls2
5 ; CHECK: Extension "SPV_KHR_float_controls2"
6 ; CHECK: OpEntryPoint Kernel %[[#KERNEL_FLOAT:]] "k_float_controls_float"
7 ; CHECK: OpEntryPoint Kernel %[[#KERNEL_ALL:]] "k_float_controls_all"
8 ; CHECK: OpEntryPoint Kernel %[[#KERNEL_FLOAT_V:]] "k_float_controls_float_v"
9 ; CHECK: OpEntryPoint Kernel %[[#KERNEL_ALL_V:]] "k_float_controls_all_v"
10
11 ; We expect 130179 for float type.
12 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_FLOAT]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079:]]
13 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079]]
14 ; We expect 0 for the rest of types because it's SignedZeroInfNanPreserve.
15 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#HALF_TYPE:]] %[[#CONST0:]]
16 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL]] FPFastMathDefault %[[#DOUBLE_TYPE:]] %[[#CONST0]]
17
18 ; We expect 130179 for float type.
19 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_FLOAT_V]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079]]
20 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#FLOAT_TYPE:]] %[[#CONST131079]]
21 ; We expect 0 for the rest of types because it's SignedZeroInfNanPreserve.
22 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#DOUBLE_TYPE:]] %[[#CONST0]]
23 ; CHECK-DAG: OpExecutionModeId %[[#KERNEL_ALL_V]] FPFastMathDefault %[[#HALF_TYPE:]] %[[#CONST0]]
24
25 ; CHECK-DAG: OpDecorate %[[#addRes:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
26 ; CHECK-DAG: OpDecorate %[[#addResH:]] FPFastMathMode None
27 ; CHECK-DAG: OpDecorate %[[#addResF:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
28 ; CHECK-DAG: OpDecorate %[[#addResD:]] FPFastMathMode None
29 ; CHECK-DAG: OpDecorate %[[#addRes_V:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
30 ; CHECK-DAG: OpDecorate %[[#addResH_V:]] FPFastMathMode None
31 ; CHECK-DAG: OpDecorate %[[#addResF_V:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowReassoc
32 ; CHECK-DAG: OpDecorate %[[#addResD_V:]] FPFastMathMode None
33
34 ; CHECK-DAG: %[[#INT32_TYPE:]] = OpTypeInt 32 0
35 ; CHECK-DAG: %[[#HALF_TYPE]] = OpTypeFloat 16
36 ; CHECK-DAG: %[[#FLOAT_TYPE]] = OpTypeFloat 32
37 ; CHECK-DAG: %[[#DOUBLE_TYPE]] = OpTypeFloat 64
38 ; CHECK-DAG: %[[#CONST0]] = OpConstantNull %[[#INT32_TYPE]]
39 ; CHECK-DAG: %[[#CONST131079]] = OpConstant %[[#INT32_TYPE]] 131079
40
41 ; CHECK-DAG: %[[#HALF_V_TYPE:]] = OpTypeVector %[[#HALF_TYPE]]
42 ; CHECK-DAG: %[[#FLOAT_V_TYPE:]] = OpTypeVector %[[#FLOAT_TYPE]]
43 ; CHECK-DAG: %[[#DOUBLE_V_TYPE:]] = OpTypeVector %[[#DOUBLE_TYPE]]
44
45 @G_addRes = global float 0.0
46 @G_addResH = global half 0.0
47 @G_addResF = global float 0.0
48 @G_addResD = global double 0.0
49 @G_addResV = global <2 x float> zeroinitializer
50 @G_addResH_V = global <2 x half> zeroinitializer
51 @G_addResF_V = global <2 x float> zeroinitializer
52 @G_addResD_V = global <2 x double> zeroinitializer
53
54 define dso_local dllexport spir_kernel void @k_float_controls_float(float %f) {
55 entry:
56 ; CHECK-DAG: %[[#addRes]] = OpFAdd %[[#FLOAT_TYPE]]
57 %addRes = fadd float %f, %f
58 store volatile float %addRes, ptr @G_addRes
59 ret void
60 }
61
62 define dso_local dllexport spir_kernel void @k_float_controls_all(half %h, float %f, double %d) {
63 entry:
64 ; CHECK-DAG: %[[#addResH]] = OpFAdd %[[#HALF_TYPE]]
65 ; CHECK-DAG: %[[#addResF]] = OpFAdd %[[#FLOAT_TYPE]]
66 ; CHECK-DAG: %[[#addResD]] = OpFAdd %[[#DOUBLE_TYPE]]
67 %addResH = fadd half %h, %h
68 store volatile half %addResH, ptr @G_addResH
69 %addResF = fadd float %f, %f
70 store volatile float %addResF, ptr @G_addResF
71 %addResD = fadd double %d, %d
72 store volatile double %addResD, ptr @G_addResD
73 ret void
74 }
75
76 define dso_local dllexport spir_kernel void @k_float_controls_float_v(<2 x float> %f) {
77 entry:
78 ; CHECK-DAG: %[[#addRes_V]] = OpFAdd %[[#FLOAT_V_TYPE]]
79 %addRes = fadd <2 x float> %f, %f
80 store volatile <2 x float> %addRes, ptr @G_addResV
81 ret void
82 }
83
84 define dso_local dllexport spir_kernel void @k_float_controls_all_v(<2 x half> %h, <2 x float> %f, <2 x double> %d) {
85 entry:
86 ; CHECK-DAG: %[[#addResH_V]] = OpFAdd %[[#HALF_V_TYPE]]
87 ; CHECK-DAG: %[[#addResF_V]] = OpFAdd %[[#FLOAT_V_TYPE]]
88 ; CHECK-DAG: %[[#addResD_V]] = OpFAdd %[[#DOUBLE_V_TYPE]]
89 %addResH = fadd <2 x half> %h, %h
90 store volatile <2 x half> %addResH, ptr @G_addResH_V
91 %addResF = fadd <2 x float> %f, %f
92 store volatile <2 x float> %addResF, ptr @G_addResF_V
93 %addResD = fadd <2 x double> %d, %d
94 store volatile <2 x double> %addResD, ptr @G_addResD_V
95 ret void
96 }
97
98 !spirv.ExecutionMode = !{!19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34}
99
100 !19 = !{ptr @k_float_controls_float, i32 6028, float poison, i32 131079}
101 !20 = !{ptr @k_float_controls_all, i32 6028, float poison, i32 131079}
102 ; ContractionOff is now replaced with FPFastMathDefault with AllowContract bit set to false.
103 !21 = !{ptr @k_float_controls_float, i32 31}
104 !22 = !{ptr @k_float_controls_all, i32 31}
105 ; SignedZeroInfNanPreserve is now replaced with FPFastMathDefault with flags 0.
106 !23 = !{ptr @k_float_controls_float, i32 4461, i32 32}
107 !24 = !{ptr @k_float_controls_all, i32 4461, i32 16}
108 !25 = !{ptr @k_float_controls_all, i32 4461, i32 32}
109 !26 = !{ptr @k_float_controls_all, i32 4461, i32 64}
110
111 !27 = !{ptr @k_float_controls_float_v, i32 6028, float poison, i32 131079}
112 !28 = !{ptr @k_float_controls_all_v, i32 6028, float poison, i32 131079}
113 ; ContractionOff is now replaced with FPFastMathDefault with AllowContract bit set to false.
114 !29 = !{ptr @k_float_controls_float_v, i32 31}
115 !30 = !{ptr @k_float_controls_all_v, i32 31}
116 ; SignedZeroInfNanPreserve is now replaced with FPFastMathDefault with flags 0.
117 !31 = !{ptr @k_float_controls_float_v, i32 4461, i32 32}
118 !32 = !{ptr @k_float_controls_all_v, i32 4461, i32 16}
119 !33 = !{ptr @k_float_controls_all_v, i32 4461, i32 32}
120 !34 = !{ptr @k_float_controls_all_v, i32 4461, i32 64}