Skip to content

Commit eb3fad5

Browse files
committed
Revert "[HLSL][clang] Add elementwise builtin for atan2 (p3) (llvm#110187)"
This reverts commit b70d327.
1 parent 8ddbd82 commit eb3fad5

18 files changed

+29
-195
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±in
660660
T __builtin_elementwise_asin(T x) return the arcsine of x interpreted as an angle in radians floating point types
661661
T __builtin_elementwise_acos(T x) return the arccosine of x interpreted as an angle in radians floating point types
662662
T __builtin_elementwise_atan(T x) return the arctangent of x interpreted as an angle in radians floating point types
663-
T __builtin_elementwise_atan2(T y, T x) return the arctangent of y/x floating point types
664663
T __builtin_elementwise_sinh(T x) return the hyperbolic sine of angle x in radians floating point types
665664
T __builtin_elementwise_cosh(T x) return the hyperbolic cosine of angle x in radians floating point types
666665
T __builtin_elementwise_tanh(T x) return the hyperbolic tangent of angle x in radians floating point types

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,6 @@ DWARF Support in Clang
575575
Floating Point Support in Clang
576576
-------------------------------
577577

578-
- Add ``__builtin_elementwise_atan2`` builtin for floating point types only.
579-
580578
Fixed Point Support in Clang
581579
----------------------------
582580

clang/include/clang/Basic/Builtins.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,12 +1250,6 @@ def ElementwiseATan : Builtin {
12501250
let Prototype = "void(...)";
12511251
}
12521252

1253-
def ElementwiseATan2 : Builtin {
1254-
let Spellings = ["__builtin_elementwise_atan2"];
1255-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1256-
let Prototype = "void(...)";
1257-
}
1258-
12591253
def ElementwiseBitreverse : Builtin {
12601254
let Spellings = ["__builtin_elementwise_bitreverse"];
12611255
let Attributes = [NoThrow, Const, CustomTypeChecking];

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,9 +3836,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
38363836
case Builtin::BI__builtin_elementwise_atan:
38373837
return RValue::get(emitBuiltinWithOneOverloadedType<1>(
38383838
*this, E, llvm::Intrinsic::atan, "elt.atan"));
3839-
case Builtin::BI__builtin_elementwise_atan2:
3840-
return RValue::get(emitBuiltinWithOneOverloadedType<2>(
3841-
*this, E, llvm::Intrinsic::atan2, "elt.atan2"));
38423839
case Builtin::BI__builtin_elementwise_ceil:
38433840
return RValue::get(emitBuiltinWithOneOverloadedType<1>(
38443841
*this, E, llvm::Intrinsic::ceil, "elt.ceil"));

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -466,36 +466,6 @@ float3 atan(float3);
466466
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
467467
float4 atan(float4);
468468

469-
//===----------------------------------------------------------------------===//
470-
// atan2 builtins
471-
//===----------------------------------------------------------------------===//
472-
473-
/// \fn T atan2(T y, T x)
474-
/// \brief Returns the arctangent of y/x, using the signs of the arguments to
475-
/// determine the correct quadrant.
476-
/// \param y The y-coordinate.
477-
/// \param x The x-coordinate.
478-
479-
#ifdef __HLSL_ENABLE_16_BIT
480-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
481-
half atan2(half y, half x);
482-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
483-
half2 atan2(half2 y, half2 x);
484-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
485-
half3 atan2(half3 y, half3 x);
486-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
487-
half4 atan2(half4 y, half4 x);
488-
#endif
489-
490-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
491-
float atan2(float y, float x);
492-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
493-
float2 atan2(float2 y, float2 x);
494-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
495-
float3 atan2(float3 y, float3 x);
496-
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
497-
float4 atan2(float4 y, float4 x);
498-
499469
//===----------------------------------------------------------------------===//
500470
// ceil builtins
501471
//===----------------------------------------------------------------------===//

clang/lib/Sema/SemaChecking.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2755,7 +2755,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
27552755

27562756
// These builtins restrict the element type to floating point
27572757
// types only, and take in two arguments.
2758-
case Builtin::BI__builtin_elementwise_atan2:
27592758
case Builtin::BI__builtin_elementwise_fmod:
27602759
case Builtin::BI__builtin_elementwise_pow: {
27612760
if (BuiltinElementwiseMath(TheCall))

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,6 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
19591959
case Builtin::BI__builtin_elementwise_acos:
19601960
case Builtin::BI__builtin_elementwise_asin:
19611961
case Builtin::BI__builtin_elementwise_atan:
1962-
case Builtin::BI__builtin_elementwise_atan2:
19631962
case Builtin::BI__builtin_elementwise_ceil:
19641963
case Builtin::BI__builtin_elementwise_cos:
19651964
case Builtin::BI__builtin_elementwise_cosh:

clang/test/CodeGen/builtins-elementwise-math.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -441,26 +441,6 @@ void test_builtin_elementwise_atan(float f1, float f2, double d1, double d2,
441441
vf2 = __builtin_elementwise_atan(vf1);
442442
}
443443

444-
void test_builtin_elementwise_atan2(float f1, float f2, float f3, double d1,
445-
double d2, double d3, float4 vf1,
446-
float4 vf2, float4 vf3) {
447-
// CHECK-LABEL: define void @test_builtin_elementwise_atan2(
448-
// CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4
449-
// CHECK-NEXT: [[F2:%.+]] = load float, ptr %f2.addr, align 4
450-
// CHECK-NEXT: call float @llvm.atan2.f32(float [[F1]], float [[F2]])
451-
f3 = __builtin_elementwise_atan2(f1, f2);
452-
453-
// CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8
454-
// CHECK-NEXT: [[D2:%.+]] = load double, ptr %d2.addr, align 8
455-
// CHECK-NEXT: call double @llvm.atan2.f64(double [[D1]], double [[D2]])
456-
d3 = __builtin_elementwise_atan2(d1, d2);
457-
458-
// CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16
459-
// CHECK-NEXT: [[VF2:%.+]] = load <4 x float>, ptr %vf2.addr, align 16
460-
// CHECK-NEXT: call <4 x float> @llvm.atan2.v4f32(<4 x float> [[VF1]], <4 x float> [[VF2]])
461-
vf3 = __builtin_elementwise_atan2(vf1, vf2);
462-
}
463-
464444
void test_builtin_elementwise_cos(float f1, float f2, double d1, double d2,
465445
float4 vf1, float4 vf2) {
466446
// CHECK-LABEL: define void @test_builtin_elementwise_cos(

clang/test/CodeGen/strictfp-elementwise-bulitins.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ float4 strict_elementwise_tanh(float4 a) {
257257
return __builtin_elementwise_tanh(a);
258258
}
259259

260-
// CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_atan2Dv4_fS_
261-
// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] {
262-
// CHECK-NEXT: entry:
263-
// CHECK-NEXT: [[ELT_ATAN2:%.*]] = tail call <4 x float> @llvm.atan2.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]]
264-
// CHECK-NEXT: ret <4 x float> [[ELT_ATAN2]]
265-
//
266-
float4 strict_elementwise_atan2(float4 a, float4 b) {
267-
return __builtin_elementwise_atan2(a, b);
268-
}
269-
270260
// CHECK-LABEL: define dso_local noundef <4 x float> @_Z24strict_elementwise_truncDv4_f
271261
// CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR2]] {
272262
// CHECK-NEXT: entry:

clang/test/CodeGenHLSL/builtins/atan2.hlsl

Lines changed: 0 additions & 59 deletions
This file was deleted.

clang/test/Sema/aarch64-sve-vector-trig-ops.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ svfloat32_t test_atan_vv_i8mf8(svfloat32_t v) {
2222
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
2323
}
2424

25-
svfloat32_t test_atan2_vv_i8mf8(svfloat32_t v) {
26-
27-
return __builtin_elementwise_atan2(v, v);
28-
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
29-
}
30-
3125
svfloat32_t test_sin_vv_i8mf8(svfloat32_t v) {
3226

3327
return __builtin_elementwise_sin(v);

clang/test/Sema/builtins-elementwise-math.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -789,30 +789,6 @@ void test_builtin_elementwise_atan(int i, float f, double d, float4 v, int3 iv,
789789
// expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
790790
}
791791

792-
void test_builtin_elementwise_atan2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
793-
794-
struct Foo s = __builtin_elementwise_atan2(f, f);
795-
// expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
796-
797-
i = __builtin_elementwise_atan2();
798-
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
799-
800-
i = __builtin_elementwise_atan2(f);
801-
// expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
802-
803-
i = __builtin_elementwise_atan2(i, i);
804-
// expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
805-
806-
i = __builtin_elementwise_atan2(f, f, f);
807-
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
808-
809-
u = __builtin_elementwise_atan2(u, u);
810-
// expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
811-
812-
uv = __builtin_elementwise_atan2(uv, uv);
813-
// expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
814-
}
815-
816792
void test_builtin_elementwise_tan(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
817793

818794
struct Foo s = __builtin_elementwise_tan(f);

clang/test/Sema/riscv-rvv-vector-trig-ops.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ vfloat32mf2_t test_asin_vv_i8mf8(vfloat32mf2_t v) {
2323
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
2424
}
2525

26-
vfloat32mf2_t test_atan2_vv_i8mf8(vfloat32mf2_t v) {
27-
28-
return __builtin_elementwise_atan2(v, v);
29-
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
30-
}
31-
3226
vfloat32mf2_t test_sin_vv_i8mf8(vfloat32mf2_t v) {
3327

3428
return __builtin_elementwise_sin(v);

clang/test/SemaCXX/builtins-elementwise-math.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ void test_builtin_elementwise_atan() {
146146
static_assert(!is_const<decltype(__builtin_elementwise_atan(b))>::value);
147147
}
148148

149-
void test_builtin_elementwise_atan2() {
150-
const float a = 42.0;
151-
float b = 42.3;
152-
static_assert(!is_const<decltype(__builtin_elementwise_atan2(a, a))>::value);
153-
static_assert(!is_const<decltype(__builtin_elementwise_atan2(b, b))>::value);
154-
}
155-
156149
void test_builtin_elementwise_tan() {
157150
const float a = 42.0;
158151
float b = 42.3;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
// 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
3+
4+
float builtin_bool_to_float_type_promotion(bool p1, bool p2) {
5+
return __builtin_elementwise_fmod(p1, p2);
6+
// expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'bool')}}
7+
}
8+
9+
float2 builtin_fmod_int2_to_float2_promotion(int2 p1, int2 p2) {
10+
return __builtin_elementwise_fmod(p1, p2);
11+
// expected-error@-1 {{1st argument must be a floating point type (was 'int2' (aka 'vector<int, 2>'))}}
12+
}
13+
14+
half builtin_fmod_double_type (double p0, double p1) {
15+
return __builtin_elementwise_fmod(p0, p1);
16+
// expected-error@-1 {{passing 'double' to parameter of incompatible type 'float'}}
17+
}
18+
19+
half builtin_fmod_double2_type (double2 p0, double2 p1) {
20+
return __builtin_elementwise_fmod(p0, p1);
21+
// 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)}}
22+
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@
1818
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_tanh
1919
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_trunc
2020

21-
double test_double_builtin(double p0) {
22-
return TEST_FUNC(p0);
23-
// expected-error@-1 {{passing 'double' to parameter of incompatible type 'float'}}
24-
}
25-
26-
double2 test_vec_double_builtin(double2 p0) {
21+
double2 test_double_builtin(double2 p0) {
2722
return TEST_FUNC(p0);
2823
// 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)}}
2924
}

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

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify
2+
3+
double2 test_double_builtin(double2 p0, double2 p1) {
4+
return __builtin_elementwise_pow(p0,p1);
5+
// 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)}}
6+
}

0 commit comments

Comments
 (0)