Skip to content

Commit 6dceea3

Browse files
authored
[HLSL] prevent generation of wrong double intrinsics. (#86932)
As #86555, we should cover all of non-double builtins. Closes #86818
1 parent 35e7d45 commit 6dceea3

File tree

5 files changed

+11
-48
lines changed

5 files changed

+11
-48
lines changed

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,6 @@ float3 ceil(float3);
243243
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
244244
float4 ceil(float4);
245245

246-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
247-
double ceil(double);
248-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
249-
double2 ceil(double2);
250-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
251-
double3 ceil(double3);
252-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
253-
double4 ceil(double4);
254-
255246
//===----------------------------------------------------------------------===//
256247
// clamp builtins
257248
//===----------------------------------------------------------------------===//
@@ -585,15 +576,6 @@ float3 floor(float3);
585576
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
586577
float4 floor(float4);
587578

588-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
589-
double floor(double);
590-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
591-
double2 floor(double2);
592-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
593-
double3 floor(double3);
594-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
595-
double4 floor(double4);
596-
597579
//===----------------------------------------------------------------------===//
598580
// frac builtins
599581
//===----------------------------------------------------------------------===//

clang/lib/Sema/SemaChecking.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5641,12 +5641,16 @@ bool Sema::CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
56415641
return true;
56425642
break;
56435643
}
5644+
case Builtin::BI__builtin_elementwise_ceil:
56445645
case Builtin::BI__builtin_elementwise_cos:
5645-
case Builtin::BI__builtin_elementwise_sin:
5646+
case Builtin::BI__builtin_elementwise_exp:
5647+
case Builtin::BI__builtin_elementwise_exp2:
5648+
case Builtin::BI__builtin_elementwise_floor:
56465649
case Builtin::BI__builtin_elementwise_log:
56475650
case Builtin::BI__builtin_elementwise_log2:
56485651
case Builtin::BI__builtin_elementwise_log10:
56495652
case Builtin::BI__builtin_elementwise_pow:
5653+
case Builtin::BI__builtin_elementwise_sin:
56505654
case Builtin::BI__builtin_elementwise_sqrt:
56515655
case Builtin::BI__builtin_elementwise_trunc: {
56525656
if (CheckFloatOrHalfRepresentations(this, TheCall))

clang/test/CodeGenHLSL/builtins/ceil.hlsl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,3 @@ float3 test_ceil_float3(float3 p0) { return ceil(p0); }
4141
// CHECK: define noundef <4 x float> @
4242
// CHECK: call <4 x float> @llvm.ceil.v4f32(
4343
float4 test_ceil_float4(float4 p0) { return ceil(p0); }
44-
45-
// CHECK: define noundef double @
46-
// CHECK: call double @llvm.ceil.f64(
47-
double test_ceil_double(double p0) { return ceil(p0); }
48-
// CHECK: define noundef <2 x double> @
49-
// CHECK: call <2 x double> @llvm.ceil.v2f64(
50-
double2 test_ceil_double2(double2 p0) { return ceil(p0); }
51-
// CHECK: define noundef <3 x double> @
52-
// CHECK: call <3 x double> @llvm.ceil.v3f64(
53-
double3 test_ceil_double3(double3 p0) { return ceil(p0); }
54-
// CHECK: define noundef <4 x double> @
55-
// CHECK: call <4 x double> @llvm.ceil.v4f64(
56-
double4 test_ceil_double4(double4 p0) { return ceil(p0); }

clang/test/CodeGenHLSL/builtins/floor.hlsl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,3 @@ float3 test_floor_float3(float3 p0) { return floor(p0); }
4141
// CHECK: define noundef <4 x float> @
4242
// CHECK: call <4 x float> @llvm.floor.v4f32(
4343
float4 test_floor_float4(float4 p0) { return floor(p0); }
44-
45-
// CHECK: define noundef double @
46-
// CHECK: call double @llvm.floor.f64(
47-
double test_floor_double(double p0) { return floor(p0); }
48-
// CHECK: define noundef <2 x double> @
49-
// CHECK: call <2 x double> @llvm.floor.v2f64(
50-
double2 test_floor_double2(double2 p0) { return floor(p0); }
51-
// CHECK: define noundef <3 x double> @
52-
// CHECK: call <3 x double> @llvm.floor.v3f64(
53-
double3 test_floor_double3(double3 p0) { return floor(p0); }
54-
// CHECK: define noundef <4 x double> @
55-
// CHECK: call <4 x double> @llvm.floor.v4f64(
56-
double4 test_floor_double4(double4 p0) { return floor(p0); }

clang/test/SemaHLSL/BuiltIns/half-float-only-errors.hlsl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_cos
2-
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_sin
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_ceil
2+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_cos
3+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_exp
4+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_exp2
5+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_floor
36
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_log
47
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_log2
58
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_log10
9+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_sin
610
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_sqrt
711
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_trunc
812

9-
1013
double2 test_double_builtin(double2 p0) {
1114
return TEST_FUNC(p0);
1215
// expected-error@-1 {{passing 'double2' (aka 'vector<double, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}

0 commit comments

Comments
 (0)