llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Farzon Lotfi (farzonl) <details> <summary>Changes</summary> - Add CustomTypeChecking to HLSL builtins that take float arguments - Add new builtin tests to confirm CustomTypeChecking doesn't promote scalar float arguments aren't promoted to double - fixes #<!-- -->133440 --- Patch is 25.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/133441.diff 18 Files Affected: - (modified) clang/include/clang/Basic/Builtins.td (+11-11) - (modified) clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl (+10-6) - (added) clang/test/CodeGenHLSL/builtins/clip-builtin.hlsl (+10) - (added) clang/test/CodeGenHLSL/builtins/degrees-builtin.hlsl (+16) - (modified) clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl (+16-23) - (added) clang/test/CodeGenHLSL/builtins/frac-builtin.hlsl (+16) - (modified) clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl (+9-12) - (added) clang/test/CodeGenHLSL/builtins/normalize-builtin.hlsl (+16) - (added) clang/test/CodeGenHLSL/builtins/radians-builtin.hlsl (+16) - (added) clang/test/CodeGenHLSL/builtins/rcp-builtin.hlsl (+16) - (added) clang/test/CodeGenHLSL/builtins/rsqrt-builtin.hlsl (+16) - (added) clang/test/CodeGenHLSL/builtins/saturate-builtin.hlsl (+16) - (modified) clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl (+4-5) - (modified) clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl (+7-2) - (modified) clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl (+13-3) - (modified) clang/test/SemaHLSL/BuiltIns/frac-errors.hlsl (-11) - (modified) clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl (+5-20) - (modified) clang/test/SemaHLSL/BuiltIns/rsqrt-errors.hlsl (+2-8) ``````````diff diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 72a5e495c4059..b2c7ddb43de55 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -4869,7 +4869,7 @@ def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> { def HLSLClamp : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_clamp"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } @@ -4881,13 +4881,13 @@ def HLSLCross: LangBuiltin<"HLSL_LANG"> { def HLSLDegrees : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_degrees"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_dot"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } @@ -4917,7 +4917,7 @@ def HLSLFirstBitLow : LangBuiltin<"HLSL_LANG"> { def HLSLFrac : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_frac"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } @@ -4929,7 +4929,7 @@ def HLSLIsinf : LangBuiltin<"HLSL_LANG"> { def HLSLLerp : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_lerp"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } @@ -4941,25 +4941,25 @@ def HLSLMad : LangBuiltin<"HLSL_LANG"> { def HLSLNormalize : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_normalize"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } def HLSLRcp : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_rcp"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } def HLSLRSqrt : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_rsqrt"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } def HLSLSaturate : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_saturate"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } @@ -4983,7 +4983,7 @@ def HLSLStep: LangBuiltin<"HLSL_LANG"> { def HLSLRadians : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_radians"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } @@ -5001,7 +5001,7 @@ def HLSLSplitDouble: LangBuiltin<"HLSL_LANG"> { def HLSLClip: LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_clip"]; - let Attributes = [NoThrow, Const]; + let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } diff --git a/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl index 62bada715a68a..356836b40e9c0 100644 --- a/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl +++ b/clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl @@ -1,8 +1,12 @@ // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s -// CHECK-LABEL: builtin_test_clamp_int4 -// CHECK: %hlsl.clamp = call <4 x i32> @llvm.dx.sclamp.v4i32(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2) -// CHECK: ret <4 x i32> %hlsl.clamp -int4 builtin_test_clamp_int4(int4 p0, int4 p1, int4 p2) { - return __builtin_hlsl_elementwise_clamp(p0, p1, p2); -} + +// CHECK-LABEL: builtin_clamp_half +// CHECK: %hlsl.clamp = call reassoc nnan ninf nsz arcp afn half @llvm.dx.nclamp.f16(half %{{.*}}, half %{{.*}}, half %{{.*}}) +// CHECK: ret half %hlsl.clamp +half builtin_clamp_half(half p0) { return __builtin_hlsl_elementwise_clamp(p0, p0, p0); } + +// CHECK-LABEL: builtin_clamp_float +// CHECK: %hlsl.clamp = call reassoc nnan ninf nsz arcp afn float @llvm.dx.nclamp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}) +// CHECK: ret float %hlsl.clamp +float builtin_clamp_float(float p0) { return __builtin_hlsl_elementwise_clamp(p0, p0, p0); } diff --git a/clang/test/CodeGenHLSL/builtins/clip-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/clip-builtin.hlsl new file mode 100644 index 0000000000000..c864f93af472b --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/clip-builtin.hlsl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + +// CHECK: define void @{{.*}}builtin_clip_float{{.*}}(float {{.*}} [[P0:%.*]]) +// CHECK: [[LOAD:%.*]] = load float, ptr [[P0]].addr, align 4 +// CHECK-NEXT: [[FCMP:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[LOAD]], 0.000000e+00 +// CHECK-NO: call i1 @llvm.dx.any +// CHECK-NEXT: call void @llvm.dx.discard(i1 [[FCMP]]) +void builtin_clip_float (float p0) { + __builtin_hlsl_elementwise_clip(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/degrees-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/degrees-builtin.hlsl new file mode 100644 index 0000000000000..2e639f5577d20 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/degrees-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_degrees_half +// CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn half @llvm.dx.degrees.f16(half %{{.*}}) +// CHECK: ret half %hlsl.degrees +half builtin_degrees_half(half p0) { + return __builtin_hlsl_elementwise_degrees(p0); +} + +// CHECK-LABEL: builtin_degrees_float +// CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn float @llvm.dx.degrees.f32(float %{{.*}}) +// CHECK: ret float %hlsl.degrees +float builtin_degrees_float (float p0) { + return __builtin_hlsl_elementwise_degrees(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl index 36c73f875e944..716704a1bfdad 100644 --- a/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl +++ b/clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl @@ -1,30 +1,23 @@ // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s -// CHECK-LABEL: builtin_bool_to_float_type_promotion -// CHECK: %conv1 = uitofp i1 %loadedv to double -// CHECK: %hlsl.dot = fmul reassoc nnan ninf nsz arcp afn double %conv, %conv1 -// CHECK: %conv2 = fptrunc reassoc nnan ninf nsz arcp afn double %hlsl.dot to float -// CHECK: ret float %conv2 -float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) { - return __builtin_hlsl_dot ( (double)p0, (double)p1 ); + +// CHECK-LABEL: builtin_dot_half +// CHECK: %hlsl.dot = fmul reassoc nnan ninf nsz arcp afn half %{{.*}}, %{{.*}} +// CHECK: ret half %hlsl.dot +half builtin_dot_half ( half p0, half p1 ) { + return __builtin_hlsl_dot (p0, p1 ); } -// CHECK-LABEL: builtin_bool_to_float_arg1_type_promotion -// CHECK: %conv = uitofp i1 %loadedv to double -// CHECK: %conv1 = fpext reassoc nnan ninf nsz arcp afn float %1 to double -// CHECK: %hlsl.dot = fmul reassoc nnan ninf nsz arcp afn double %conv, %conv1 -// CHECK: %conv2 = fptrunc reassoc nnan ninf nsz arcp afn double %hlsl.dot to float -// CHECK: ret float %conv2 -float builtin_bool_to_float_arg1_type_promotion ( bool p0, float p1 ) { - return __builtin_hlsl_dot ( (double)p0, (double)p1 ); +// CHECK-LABEL: builtin_dot_float +// CHECK: %hlsl.dot = fmul reassoc nnan ninf nsz arcp afn float %{{.*}}, %{{.*}} +// CHECK: ret float %hlsl.dot +float builtin_dot_float ( float p0, float p1 ) { + return __builtin_hlsl_dot (p0, p1 ); } -// CHECK-LABEL: builtin_dot_int_to_float_promotion -// CHECK: %conv = fpext reassoc nnan ninf nsz arcp afn float %0 to double -// CHECK: %conv1 = sitofp i32 %1 to double -// CHECK: dot = fmul reassoc nnan ninf nsz arcp afn double %conv, %conv1 -// CHECK: %conv2 = fptrunc reassoc nnan ninf nsz arcp afn double %hlsl.dot to float -// CHECK: ret float %conv2 -float builtin_dot_int_to_float_promotion ( float p0, int p1 ) { - return __builtin_hlsl_dot ( (double)p0, (double)p1 ); +// CHECK-LABEL: builtin_dot_double +// CHECK: %hlsl.dot = fmul reassoc nnan ninf nsz arcp afn double %{{.*}}, %{{.*}} +// CHECK: ret double %hlsl.dot +double builtin_dot_double( double p0, double p1 ) { + return __builtin_hlsl_dot (p0, p1 ); } diff --git a/clang/test/CodeGenHLSL/builtins/frac-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/frac-builtin.hlsl new file mode 100644 index 0000000000000..9f144f470ed90 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/frac-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_frac_half +// CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn half @llvm.dx.frac.f16(half %{{.*}}) +// CHECK: ret half %hlsl.frac +half builtin_frac_half(half p0) { + return __builtin_hlsl_elementwise_frac(p0); +} + +// CHECK-LABEL: builtin_frac_float +// CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn float @llvm.dx.frac.f32(float %{{.*}}) +// CHECK: ret float %hlsl.frac +float builtin_frac_float (float p0) { + return __builtin_hlsl_elementwise_frac(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl index c98693f32c834..96bcf2b49bf25 100644 --- a/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl +++ b/clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl @@ -1,15 +1,12 @@ // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s -// CHECK-LABEL: builtin_lerp_half_vector -// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x half> @llvm.dx.lerp.v3f16(<3 x half> %0, <3 x half> %1, <3 x half> %2) -// CHECK: ret <3 x half> %hlsl.lerp -half3 builtin_lerp_half_vector (half3 p0) { - return __builtin_hlsl_lerp ( p0, p0, p0 ); -} -// CHECK-LABEL: builtin_lerp_floar_vector -// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 x float> %1, <2 x float> %2) -// CHECK: ret <2 x float> %hlsl.lerp -float2 builtin_lerp_floar_vector ( float2 p0) { - return __builtin_hlsl_lerp ( p0, p0, p0 ); -} +// CHECK-LABEL: builtin_lerp_half +// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn half @llvm.dx.lerp.f16(half %{{.*}}, half %{{.*}}, half %{{.*}}) +// CHECK: ret half %hlsl.lerp +half builtin_lerp_half(half p0) { return __builtin_hlsl_lerp(p0, p0, p0); } + +// CHECK-LABEL: builtin_lerp_float +// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float @llvm.dx.lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}) +// CHECK: ret float %hlsl.lerp +float builtin_lerp_float(float p0) { return __builtin_hlsl_lerp(p0, p0, p0); } diff --git a/clang/test/CodeGenHLSL/builtins/normalize-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/normalize-builtin.hlsl new file mode 100644 index 0000000000000..3db64604a1319 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/normalize-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_normalize_half +// CHECK: %hlsl.normalize = call reassoc nnan ninf nsz arcp afn half @llvm.dx.normalize.f16(half %{{.*}}) +// CHECK: ret half %hlsl.normalize +half builtin_normalize_half(half p0) { + return __builtin_hlsl_normalize(p0); +} + +// CHECK-LABEL: builtin_normalize_float +// CHECK: %hlsl.normalize = call reassoc nnan ninf nsz arcp afn float @llvm.dx.normalize.f32(float %{{.*}}) +// CHECK: ret float %hlsl.normalize +float builtin_normalize_float (float p0) { + return __builtin_hlsl_normalize(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/radians-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/radians-builtin.hlsl new file mode 100644 index 0000000000000..0c86357d5ecad --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/radians-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_radians_half +// CHECK: %hlsl.radians = call reassoc nnan ninf nsz arcp afn half @llvm.dx.radians.f16(half %{{.*}}) +// CHECK: ret half %hlsl.radians +half builtin_radians_half(half p0) { + return __builtin_hlsl_elementwise_radians(p0); +} + +// CHECK-LABEL: builtin_radians_float +// CHECK: %hlsl.radians = call reassoc nnan ninf nsz arcp afn float @llvm.dx.radians.f32(float %{{.*}}) +// CHECK: ret float %hlsl.radians +float builtin_radians_float (float p0) { + return __builtin_hlsl_elementwise_radians(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/rcp-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/rcp-builtin.hlsl new file mode 100644 index 0000000000000..d81a49b8c6048 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/rcp-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_rcp_half +// CHECK: %hlsl.rcp = fdiv reassoc nnan ninf nsz arcp afn half 0xH3C00, %{{.*}} +// CHECK: ret half %hlsl.rcp +half builtin_rcp_half(half p0) { + return __builtin_hlsl_elementwise_rcp(p0); +} + +// CHECK-LABEL: builtin_rcp_float +// CHECK: %hlsl.rcp = fdiv reassoc nnan ninf nsz arcp afn float 1.000000e+00, %{{.*}} +// CHECK: ret float %hlsl.rcp +float builtin_rcp_float(float p0) { + return __builtin_hlsl_elementwise_rcp(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/rsqrt-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/rsqrt-builtin.hlsl new file mode 100644 index 0000000000000..43ad9d0d0b844 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/rsqrt-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_rsqrt_half +// CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn half @llvm.dx.rsqrt.f16(half %{{.*}}) +// CHECK: ret half %hlsl.rsqrt +half builtin_rsqrt_half(half p0) { + return __builtin_hlsl_elementwise_rsqrt(p0); +} + +// CHECK-LABEL: builtin_rsqrt_float +// CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn float @llvm.dx.rsqrt.f32(float %{{.*}}) +// CHECK: ret float %hlsl.rsqrt +float builtin_rsqrt_float (float p0) { + return __builtin_hlsl_elementwise_rsqrt(p0); +} diff --git a/clang/test/CodeGenHLSL/builtins/saturate-builtin.hlsl b/clang/test/CodeGenHLSL/builtins/saturate-builtin.hlsl new file mode 100644 index 0000000000000..7dbba72f3abb5 --- /dev/null +++ b/clang/test/CodeGenHLSL/builtins/saturate-builtin.hlsl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s + + +// CHECK-LABEL: builtin_saturate_half +// CHECK: %hlsl.saturate = call reassoc nnan ninf nsz arcp afn half @llvm.dx.saturate.f16(half %{{.*}}) +// CHECK: ret half %hlsl.saturate +half builtin_saturate_half(half p0) { + return __builtin_hlsl_elementwise_saturate(p0); +} + +// CHECK-LABEL: builtin_saturate_float +// CHECK: %hlsl.saturate = call reassoc nnan ninf nsz arcp afn float @llvm.dx.saturate.f32(float %{{.*}}) +// CHECK: ret float %hlsl.saturate +float builtin_saturate_float (float p0) { + return __builtin_hlsl_elementwise_saturate(p0); +} diff --git a/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl index 71c16e9cf9ff2..fba7820e4f4df 100644 --- a/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl @@ -35,9 +35,9 @@ float2 test_scalar_first_arg3(float p0, float2 p1) { // expected-error@-1 {{call to 'clamp' is ambiguous}} } -float3 test_thing(float3 p0, float2 p1) { +float3 test_clamp_vector_size_last_arg_mismatch(float3 p0, float2 p1) { return clamp(p0, p0, p1); - // expected-error@-1 {{cannot initialize return object of type 'float3' (aka 'vector<float, 3>') with an rvalue of type 'vector<float, 2>' (vector of 2 'float' values)}} + // expected-error@-1 {{all arguments to 'clamp' must have the same type}} } typedef float float5 __attribute__((ext_vector_type(5))); @@ -48,13 +48,12 @@ float5 vec_too_big(float5 p0) { // expected-error@-1 {{call to 'clamp' is ambiguous}} } -float2 test_clamp_vector_size_mismatch(float3 p0, float2 p1) { +float2 test_clamp_vector_size_ret_mismatch(float3 p0, float3 p1) { return clamp(p0, p0, p1); // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'vector<float, 2>' (vector of 2 'float' values)}} - // expected-warning@-2 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'vector<float, 2>' (vector of 2 'float' values)}} } -float2 test_clamp_builtin_vector_size_mismatch(float3 p0, float2 p1) { +float2 test_clamp_builtin_vector_size_first_arg_mismatch(float3 p0, float2 p1) { return __builtin_hlsl_elementwise_clamp(p0, p1, p1); // expected-error@-1 {{all arguments to '__builtin_hlsl_elementwise_clamp' must have the same type}} } diff --git a/clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl index 871e512e128c5..2cb401601f7eb 100644 --- a/clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl @@ -16,12 +16,17 @@ void test_first_arg_type_mismatch(bool p) { // expected-error@-1 {{invalid operand of type 'bool' where 'float' or a vector of such type is required}} } -void test_first_arg_type_mismatch_3(half3 p) { +void test_first_arg_type_mismatch_2(half3 p) { __builtin_hlsl_elementwise_clip(p); // expected-error@-1 {{invalid operand of type 'half3' (aka 'vector<half, 3>') where 'float' or a vector of such type is required}} } -void test_first_arg_type_mismatch_3(double p) { +void test_first_arg_type_mismatch_3(half p) { + __builtin_hlsl_elementwise_clip(p); + // expected-error@-1 {{invalid operand of type 'half' where 'float' or a vector of such type is required}} +} + +void test_first_arg_type_mismatch_4(double p) { __builtin_hlsl_elementwise_clip(p); // expected-error@-1 {{invalid operand of type 'double' where 'float' or a vector of such type is required}} } diff --git a/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl index 157f5e2575b03..d8a7e0c640b68 100644 --- a/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl +++ b/clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected=note float test_no_second_arg(float2 p0) { return __builtin_hlsl_dot(p0); @@ -17,7 +17,7 @@ float test_dot_no_second_arg(float2 p0) { float test_dot_vector_size_mismatch(float3 p0, float2 p1) { return dot(p0, p1); - // expected-warning@-1 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'vector<float, 2>' (vector of 2 'float' values)}} + // expected-error@-1 {{all arguments to 'dot' must have the same type}} } float test_dot_builtin_vector_size_mismatch(float3 p0, float2 p1) { @@ -104,7 +10... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/133441 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits