Skip to content

Commit ac7c175

Browse files
committed
address pr comments - add int and mismatched args error tests, remove spirv double test
1 parent 8eaea32 commit ac7c175

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

clang/test/CodeGenSPIRV/Builtins/smoothstep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ float3 test_smoothstep_float3(float3 Min, float3 Max, float3 X) { return __built
4242
//
4343
float4 test_smoothstep_float4(float4 Min, float4 Max, float4 X) { return __builtin_spirv_smoothstep(Min, Max, X); }
4444

45+
// CHECK-LABEL: define spir_func double @test_smoothstep_double(
46+
// CHECK-SAME: double noundef [[MIN:%.*]], double noundef [[MAX:%.*]], double noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
47+
// CHECK-NEXT: [[ENTRY:.*:]]
48+
// CHECK-NEXT: [[SPV_SMOOTHSTEP:%.*]] = tail call double @llvm.spv.smoothstep.f64(double [[MIN]], double [[MAX]], double [[X]])
49+
// CHECK-NEXT: ret double [[SPV_SMOOTHSTEP]]
50+
//
51+
double test_smoothstep_double(double Min, double Max, double X) { return __builtin_spirv_smoothstep(Min, Max, X); }

clang/test/SemaSPIRV/BuiltIns/smoothstep-errors.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 %s -triple spirv-pc-vulkan-compute -verify
22

33
typedef float float2 __attribute__((ext_vector_type(2)));
4+
typedef float float3 __attribute__((ext_vector_type(3)));
45

56
float2 test_no_second_arg(float2 p0) {
67
return __builtin_spirv_smoothstep(p0);
@@ -16,3 +17,28 @@ float2 test_too_many_arg(float2 p0) {
1617
return __builtin_spirv_smoothstep(p0, p0, p0, p0);
1718
// expected-error@-1 {{too many arguments to function call, expected 3, have 4}}
1819
}
20+
21+
int test_int_scalar_inputs(int p0) {
22+
return __builtin_spirv_smoothstep(p0, p0, p0);
23+
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
24+
}
25+
26+
float test_mismatched_arg(float p0, float2 p1) {
27+
return __builtin_spirv_smoothstep(p0, p1, p1);
28+
// expected-error@-1 {{all arguments to '__builtin_spirv_smoothstep' must have the same type}}
29+
}
30+
31+
float test_mismatched_arg2(float p0, float2 p1) {
32+
return __builtin_spirv_smoothstep(p0, p0, p1);
33+
// expected-error@-1 {{all arguments to '__builtin_spirv_smoothstep' must have the same type}}
34+
}
35+
36+
float test_mismatched_return(float2 p0) {
37+
return __builtin_spirv_smoothstep(p0, p0, p0);
38+
// expected-error@-1 {{returning 'float2' (vector of 2 'float' values) from a function with incompatible result type 'float'}}
39+
}
40+
41+
float3 test_mismatched_return2(float2 p0) {
42+
return __builtin_spirv_smoothstep(p0, p0, p0);
43+
// expected-error@-1 {{returning 'float2' (vector of 2 'float' values) from a function with incompatible result type 'float3' (vector of 3 'float' values)}}
44+
}

0 commit comments

Comments
 (0)