Skip to content

Commit 9398b77

Browse files
committed
Add CustomTypeChecking, fix codegen tests
1 parent 32df840 commit 9398b77

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

clang/include/clang/Basic/BuiltinsSPIRV.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ def SPIRVReflect : Builtin {
2828

2929
def SPIRVSmoothStep : Builtin {
3030
let Spellings = ["__builtin_spirv_smoothstep"];
31-
let Attributes = [NoThrow, Const];
31+
let Attributes = [NoThrow, Const, CustomTypeChecking];
3232
let Prototype = "void(...)";
3333
}

clang/test/CodeGenHLSL/builtins/smoothstep.hlsl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@
2222
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) half @_Z20test_smoothstep_halfDhDhDh(
2323
// SPVCHECK-SAME: half noundef nofpclass(nan inf) [[MIN:%.*]], half noundef nofpclass(nan inf) [[MAX:%.*]], half noundef nofpclass(nan inf) [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
2424
// SPVCHECK-NEXT: [[ENTRY:.*:]]
25-
// SPVCHECK-NEXT: [[CONV_I:%.*]] = fpext reassoc nnan ninf nsz arcp afn half [[MIN]] to double
26-
// SPVCHECK-NEXT: [[CONV1_I:%.*]] = fpext reassoc nnan ninf nsz arcp afn half [[MAX]] to double
27-
// SPVCHECK-NEXT: [[CONV2_I:%.*]] = fpext reassoc nnan ninf nsz arcp afn half [[X]] to double
28-
// SPVCHECK-NEXT: [[SPV_SMOOTHSTEP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn double @llvm.spv.smoothstep.f64(double [[CONV_I]], double [[CONV1_I]], double [[CONV2_I]])
29-
// SPVCHECK-NEXT: [[CONV3_I:%.*]] = fptrunc reassoc nnan ninf nsz arcp afn double [[SPV_SMOOTHSTEP_I]] to half
30-
// SPVCHECK-NEXT: ret half [[CONV3_I]]
25+
// SPVCHECK-NEXT: [[SPV_SMOOTHSTEP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef half @llvm.spv.smoothstep.f16(half [[MIN]], half [[MAX]], half [[X]])
26+
// SPVCHECK-NEXT: ret half [[SPV_SMOOTHSTEP_I]]
3127
//
3228
half test_smoothstep_half(half Min, half Max, half X) { return smoothstep(Min, Max, X); }
3329

@@ -110,12 +106,8 @@ half4 test_smoothstep_half4(half4 Min, half4 Max, half4 X) { return smoothstep(M
110106
// SPVCHECK-LABEL: define spir_func noundef nofpclass(nan inf) float @_Z21test_smoothstep_floatfff(
111107
// SPVCHECK-SAME: float noundef nofpclass(nan inf) [[MIN:%.*]], float noundef nofpclass(nan inf) [[MAX:%.*]], float noundef nofpclass(nan inf) [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
112108
// SPVCHECK-NEXT: [[ENTRY:.*:]]
113-
// SPVCHECK-NEXT: [[CONV_I:%.*]] = fpext reassoc nnan ninf nsz arcp afn float [[MIN]] to double
114-
// SPVCHECK-NEXT: [[CONV1_I:%.*]] = fpext reassoc nnan ninf nsz arcp afn float [[MAX]] to double
115-
// SPVCHECK-NEXT: [[CONV2_I:%.*]] = fpext reassoc nnan ninf nsz arcp afn float [[X]] to double
116-
// SPVCHECK-NEXT: [[SPV_SMOOTHSTEP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn double @llvm.spv.smoothstep.f64(double [[CONV_I]], double [[CONV1_I]], double [[CONV2_I]])
117-
// SPVCHECK-NEXT: [[CONV3_I:%.*]] = fptrunc reassoc nnan ninf nsz arcp afn double [[SPV_SMOOTHSTEP_I]] to float
118-
// SPVCHECK-NEXT: ret float [[CONV3_I]]
109+
// SPVCHECK-NEXT: [[SPV_SMOOTHSTEP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn noundef float @llvm.spv.smoothstep.f32(float [[MIN]], float [[MAX]], float [[X]])
110+
// SPVCHECK-NEXT: ret float [[SPV_SMOOTHSTEP_I]]
119111
//
120112
float test_smoothstep_float(float Min, float Max, float X) { return smoothstep(Min, Max, X); }
121113

clang/test/CodeGenSPIRV/Builtins/smoothstep.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ typedef float float4 __attribute__((ext_vector_type(4)));
99
// CHECK-LABEL: define spir_func float @test_smoothstep_float(
1010
// CHECK-SAME: float noundef [[MIN:%.*]], float noundef [[MAX:%.*]], float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
1111
// CHECK-NEXT: [[ENTRY:.*:]]
12-
// CHECK-NEXT: [[CONV:%.*]] = fpext float [[MIN]] to double
13-
// CHECK-NEXT: [[CONV1:%.*]] = fpext float [[MAX]] to double
14-
// CHECK-NEXT: [[CONV2:%.*]] = fpext float [[X]] to double
15-
// CHECK-NEXT: [[SPV_SMOOTHSTEP:%.*]] = tail call double @llvm.spv.smoothstep.f64(double [[CONV]], double [[CONV1]], double [[CONV2]])
16-
// CHECK-NEXT: [[CONV3:%.*]] = fptrunc double [[SPV_SMOOTHSTEP]] to float
17-
// CHECK-NEXT: ret float [[CONV3]]
12+
// CHECK-NEXT: [[SPV_SMOOTHSTEP:%.*]] = tail call float @llvm.spv.smoothstep.f32(float [[MIN]], float [[MAX]], float [[X]])
13+
// CHECK-NEXT: ret float [[SPV_SMOOTHSTEP]]
1814
//
1915
float test_smoothstep_float(float Min, float Max, float X) { return __builtin_spirv_smoothstep(Min, Max, X); }
2016

0 commit comments

Comments
 (0)