Skip to content

Commit 2c9a706

Browse files
committed
[HLSL] Make lerp overload tests stricter. NFC
These tests had checks across multiple functions, because none of the hlsl header implementation functions were inlined. Switch the run lines to use -O1 instead of -disable-llvm-passes and rewrite the tests to actually look at the whole function. Note - this would be simpler with update_cc_test_checks, but the differences between DX and SPIRV are difficult to account for with those scripts.
1 parent 4ed8f38 commit 2c9a706

File tree

1 file changed

+121
-69
lines changed

1 file changed

+121
-69
lines changed
Lines changed: 121 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,160 @@
1-
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
2-
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
3-
// RUN: -o - | FileCheck %s --check-prefixes=CHECK \
4-
// RUN: -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
5-
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
6-
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
7-
// RUN: -o - | FileCheck %s --check-prefixes=CHECK \
8-
// RUN: -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTARGET=spv
9-
10-
// CHECK-LABEL: test_lerp_double
11-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
12-
// CHECK: ret float %hlsl.lerp
1+
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -emit-llvm -O1 -o - | FileCheck %s --check-prefixes=CHECK -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
2+
// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple spirv-unknown-vulkan-compute %s -emit-llvm -O1 -o - | FileCheck %s --check-prefixes=CHECK -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTARGET=spv
3+
4+
// CHECK: define [[FNATTRS]] float @_Z16test_lerp_doubled(
5+
// CHECK-NEXT: [[ENTRY:.*:]]
6+
// CHECK-NEXT: [[CONV:%.*]] = fptrunc {{.*}} double [[P0:%.*]] to float
7+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
8+
// CHECK-NEXT: ret float [[LERP]]
139
float test_lerp_double(double p0) { return lerp(p0, p0, p0); }
1410

15-
// CHECK-LABEL: test_lerp_double2
16-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x float> %{{.*}})
17-
// CHECK: ret <2 x float> %hlsl.lerp
11+
// CHECK: define [[FNATTRS]] <2 x float> @_Z17test_lerp_double2Dv2_d(
12+
// CHECK-NEXT: [[ENTRY:.*:]]
13+
// CHECK-NEXT: [[CONV:%.*]] = fptrunc {{.*}} <2 x double> [[P0:%.*]] to <2 x float>
14+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x float> [[CONV]])
15+
// CHECK-NEXT: ret <2 x float> [[LERP]]
1816
float2 test_lerp_double2(double2 p0) { return lerp(p0, p0, p0); }
1917

20-
// CHECK-LABEL: test_lerp_double3
21-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x float> %{{.*}})
22-
// CHECK: ret <3 x float> %hlsl.lerp
18+
// CHECK: define [[FNATTRS]] <3 x float> @_Z17test_lerp_double3Dv3_d(
19+
// CHECK-NEXT: [[ENTRY:.*:]]
20+
// CHECK-NEXT: [[CONV:%.*]] = fptrunc {{.*}} <3 x double> [[P0:%.*]] to <3 x float>
21+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x float> [[CONV]])
22+
// CHECK-NEXT: ret <3 x float> [[LERP]]
23+
//
2324
float3 test_lerp_double3(double3 p0) { return lerp(p0, p0, p0); }
2425

25-
// CHECK-LABEL: test_lerp_double4
26-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
27-
// CHECK: ret <4 x float> %hlsl.lerp
26+
// CHECK: define [[FNATTRS]] <4 x float> @_Z17test_lerp_double4Dv4_d(
27+
// CHECK-NEXT: [[ENTRY:.*:]]
28+
// CHECK-NEXT: [[CONV:%.*]] = fptrunc {{.*}} <4 x double> [[P0:%.*]] to <4 x float>
29+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV]], <4 x float> [[CONV]], <4 x float> [[CONV]])
30+
// CHECK-NEXT: ret <4 x float> [[LERP]]
31+
//
2832
float4 test_lerp_double4(double4 p0) { return lerp(p0, p0, p0); }
2933

30-
// CHECK-LABEL: test_lerp_int
31-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
32-
// CHECK: ret float %hlsl.lerp
34+
// CHECK: define [[FNATTRS]] float @_Z13test_lerp_inti(
35+
// CHECK-NEXT: [[ENTRY:.*:]]
36+
// CHECK-NEXT: [[CONV:%.*]] = sitofp i32 [[P0:%.*]] to float
37+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
38+
// CHECK-NEXT: ret float [[LERP]]
39+
//
3340
float test_lerp_int(int p0) { return lerp(p0, p0, p0); }
3441

35-
// CHECK-LABEL: test_lerp_int2
36-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x float> %{{.*}})
37-
// CHECK: ret <2 x float> %hlsl.lerp
42+
// CHECK: define [[FNATTRS]] <2 x float> @_Z14test_lerp_int2Dv2_i(
43+
// CHECK-NEXT: [[ENTRY:.*:]]
44+
// CHECK-NEXT: [[CONV:%.*]] = sitofp <2 x i32> [[P0:%.*]] to <2 x float>
45+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x float> [[CONV]])
46+
// CHECK-NEXT: ret <2 x float> [[LERP]]
47+
//
3848
float2 test_lerp_int2(int2 p0) { return lerp(p0, p0, p0); }
3949

40-
// CHECK-LABEL: test_lerp_int3
41-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x float> %{{.*}})
42-
// CHECK: ret <3 x float> %hlsl.lerp
50+
// CHECK: define [[FNATTRS]] <3 x float> @_Z14test_lerp_int3Dv3_i(
51+
// CHECK-NEXT: [[ENTRY:.*:]]
52+
// CHECK-NEXT: [[CONV:%.*]] = sitofp <3 x i32> [[P0:%.*]] to <3 x float>
53+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x float> [[CONV]])
54+
// CHECK-NEXT: ret <3 x float> [[LERP]]
55+
//
4356
float3 test_lerp_int3(int3 p0) { return lerp(p0, p0, p0); }
4457

45-
// CHECK-LABEL: test_lerp_int4
46-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
47-
// CHECK: ret <4 x float> %hlsl.lerp
58+
// CHECK: define [[FNATTRS]] <4 x float> @_Z14test_lerp_int4Dv4_i(
59+
// CHECK-NEXT: [[ENTRY:.*:]]
60+
// CHECK-NEXT: [[CONV:%.*]] = sitofp <4 x i32> [[P0:%.*]] to <4 x float>
61+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV]], <4 x float> [[CONV]], <4 x float> [[CONV]])
62+
// CHECK-NEXT: ret <4 x float> [[LERP]]
63+
//
4864
float4 test_lerp_int4(int4 p0) { return lerp(p0, p0, p0); }
4965

50-
// CHECK-LABEL: test_lerp_uint
51-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
52-
// CHECK: ret float %hlsl.lerp
66+
// CHECK: define [[FNATTRS]] float @_Z14test_lerp_uintj(
67+
// CHECK-NEXT: [[ENTRY:.*:]]
68+
// CHECK-NEXT: [[CONV:%.*]] = uitofp i32 [[P0:%.*]] to float
69+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
70+
// CHECK-NEXT: ret float [[LERP]]
71+
//
5372
float test_lerp_uint(uint p0) { return lerp(p0, p0, p0); }
5473

55-
// CHECK-LABEL: test_lerp_uint2
56-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x float> %{{.*}})
57-
// CHECK: ret <2 x float> %hlsl.lerp
74+
// CHECK: define [[FNATTRS]] <2 x float> @_Z15test_lerp_uint2Dv2_j(
75+
// CHECK-NEXT: [[ENTRY:.*:]]
76+
// CHECK-NEXT: [[CONV:%.*]] = uitofp <2 x i32> [[P0:%.*]] to <2 x float>
77+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x float> [[CONV]])
78+
// CHECK-NEXT: ret <2 x float> [[LERP]]
79+
//
5880
float2 test_lerp_uint2(uint2 p0) { return lerp(p0, p0, p0); }
5981

60-
// CHECK-LABEL: test_lerp_uint3
61-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x float> %{{.*}})
62-
// CHECK: ret <3 x float> %hlsl.lerp
82+
// CHECK: define [[FNATTRS]] <3 x float> @_Z15test_lerp_uint3Dv3_j(
83+
// CHECK-NEXT: [[ENTRY:.*:]]
84+
// CHECK-NEXT: [[CONV:%.*]] = uitofp <3 x i32> [[P0:%.*]] to <3 x float>
85+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x float> [[CONV]])
86+
// CHECK-NEXT: ret <3 x float> [[LERP]]
87+
//
6388
float3 test_lerp_uint3(uint3 p0) { return lerp(p0, p0, p0); }
6489

65-
// CHECK-LABEL: test_lerp_uint4
66-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
67-
// CHECK: ret <4 x float> %hlsl.lerp
90+
// CHECK: define [[FNATTRS]] <4 x float> @_Z15test_lerp_uint4Dv4_j(
91+
// CHECK-NEXT: [[ENTRY:.*:]]
92+
// CHECK-NEXT: [[CONV:%.*]] = uitofp <4 x i32> [[P0:%.*]] to <4 x float>
93+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV]], <4 x float> [[CONV]], <4 x float> [[CONV]])
94+
// CHECK-NEXT: ret <4 x float> [[LERP]]
95+
//
6896
float4 test_lerp_uint4(uint4 p0) { return lerp(p0, p0, p0); }
6997

70-
// CHECK-LABEL: test_lerp_int64_t
71-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
72-
// CHECK: ret float %hlsl.lerp
98+
// CHECK: define [[FNATTRS]] float @_Z17test_lerp_int64_tl(
99+
// CHECK-NEXT: [[ENTRY:.*:]]
100+
// CHECK-NEXT: [[CONV:%.*]] = sitofp i64 [[P0:%.*]] to float
101+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
102+
// CHECK-NEXT: ret float [[LERP]]
103+
//
73104
float test_lerp_int64_t(int64_t p0) { return lerp(p0, p0, p0); }
74105

75-
// CHECK-LABEL: test_lerp_int64_t2
76-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x float> %{{.*}})
77-
// CHECK: ret <2 x float> %hlsl.lerp
106+
// CHECK: define [[FNATTRS]] <2 x float> @_Z18test_lerp_int64_t2Dv2_l(
107+
// CHECK-NEXT: [[ENTRY:.*:]]
108+
// CHECK-NEXT: [[CONV:%.*]] = sitofp <2 x i64> [[P0:%.*]] to <2 x float>
109+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x float> [[CONV]])
110+
// CHECK-NEXT: ret <2 x float> [[LERP]]
111+
//
78112
float2 test_lerp_int64_t2(int64_t2 p0) { return lerp(p0, p0, p0); }
79113

80-
// CHECK-LABEL: test_lerp_int64_t3
81-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x float> %{{.*}})
82-
// CHECK: ret <3 x float> %hlsl.lerp
114+
// CHECK: define [[FNATTRS]] <3 x float> @_Z18test_lerp_int64_t3Dv3_l(
115+
// CHECK-NEXT: [[ENTRY:.*:]]
116+
// CHECK-NEXT: [[CONV:%.*]] = sitofp <3 x i64> [[P0:%.*]] to <3 x float>
117+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x float> [[CONV]])
118+
// CHECK-NEXT: ret <3 x float> [[LERP]]
119+
//
83120
float3 test_lerp_int64_t3(int64_t3 p0) { return lerp(p0, p0, p0); }
84121

85-
// CHECK-LABEL: test_lerp_int64_t4
86-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
87-
// CHECK: ret <4 x float> %hlsl.lerp
122+
// CHECK: define [[FNATTRS]] <4 x float> @_Z18test_lerp_int64_t4Dv4_l(
123+
// CHECK-NEXT: [[ENTRY:.*:]]
124+
// CHECK-NEXT: [[CONV:%.*]] = sitofp <4 x i64> [[P0:%.*]] to <4 x float>
125+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV]], <4 x float> [[CONV]], <4 x float> [[CONV]])
126+
// CHECK-NEXT: ret <4 x float> [[LERP]]
127+
//
88128
float4 test_lerp_int64_t4(int64_t4 p0) { return lerp(p0, p0, p0); }
89129

90-
// CHECK-LABEL: test_lerp_uint64_t
91-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
92-
// CHECK: ret float %hlsl.lerp
130+
// CHECK: define [[FNATTRS]] float @_Z18test_lerp_uint64_tm(
131+
// CHECK-NEXT: [[ENTRY:.*:]]
132+
// CHECK-NEXT: [[CONV:%.*]] = uitofp i64 [[P0:%.*]] to float
133+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} float @llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
134+
// CHECK-NEXT: ret float [[LERP]]
135+
//
93136
float test_lerp_uint64_t(uint64_t p0) { return lerp(p0, p0, p0); }
94137

95-
// CHECK-LABEL: test_lerp_uint64_t2
96-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x float> %{{.*}})
97-
// CHECK: ret <2 x float> %hlsl.lerp
138+
// CHECK: define [[FNATTRS]] <2 x float> @_Z19test_lerp_uint64_t2Dv2_m(
139+
// CHECK-NEXT: [[ENTRY:.*:]]
140+
// CHECK-NEXT: [[CONV:%.*]] = uitofp <2 x i64> [[P0:%.*]] to <2 x float>
141+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <2 x float> @llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x float> [[CONV]])
142+
// CHECK-NEXT: ret <2 x float> [[LERP]]
143+
//
98144
float2 test_lerp_uint64_t2(uint64_t2 p0) { return lerp(p0, p0, p0); }
99145

100-
// CHECK-LABEL: test_lerp_uint64_t3
101-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x float> %{{.*}})
102-
// CHECK: ret <3 x float> %hlsl.lerp
146+
// CHECK: define [[FNATTRS]] <3 x float> @_Z19test_lerp_uint64_t3Dv3_m(
147+
// CHECK-NEXT: [[ENTRY:.*:]]
148+
// CHECK-NEXT: [[CONV:%.*]] = uitofp <3 x i64> [[P0:%.*]] to <3 x float>
149+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <3 x float> @llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x float> [[CONV]])
150+
// CHECK-NEXT: ret <3 x float> [[LERP]]
151+
//
103152
float3 test_lerp_uint64_t3(uint64_t3 p0) { return lerp(p0, p0, p0); }
104153

105-
// CHECK-LABEL: test_lerp_uint64_t4
106-
// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
107-
// CHECK: ret <4 x float> %hlsl.lerp
154+
// CHECK: define [[FNATTRS]] <4 x float> @_Z19test_lerp_uint64_t4Dv4_m(
155+
// CHECK-NEXT: [[ENTRY:.*:]]
156+
// CHECK-NEXT: [[CONV:%.*]] = uitofp <4 x i64> [[P0:%.*]] to <4 x float>
157+
// CHECK-NEXT: [[LERP:%.*]] = tail call {{.*}} <4 x float> @llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV]], <4 x float> [[CONV]], <4 x float> [[CONV]])
158+
// CHECK-NEXT: ret <4 x float> [[LERP]]
159+
//
108160
float4 test_lerp_uint64_t4(uint64_t4 p0) { return lerp(p0, p0, p0); }

0 commit comments

Comments
 (0)