Skip to content

Commit 4703f8b

Browse files
authored
clang/HIP: Use generic builtins for f32 exp and log (#129638)
Stop using ocml declarations which are just a shim around the intrinsics.
1 parent be5149a commit 4703f8b

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

clang/lib/Headers/__clang_hip_math.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ __DEVICE__
392392
float erfinvf(float __x) { return __ocml_erfinv_f32(__x); }
393393

394394
__DEVICE__
395-
float exp10f(float __x) { return __ocml_exp10_f32(__x); }
395+
float exp10f(float __x) { return __builtin_exp10f(__x); }
396396

397397
__DEVICE__
398398
float exp2f(float __x) { return __builtin_exp2f(__x); }
@@ -495,13 +495,13 @@ __DEVICE__
495495
float log1pf(float __x) { return __ocml_log1p_f32(__x); }
496496

497497
__DEVICE__
498-
float log2f(float __x) { return __FAST_OR_SLOW(__log2f, __ocml_log2_f32)(__x); }
498+
float log2f(float __x) { return __FAST_OR_SLOW(__log2f, __builtin_log2f)(__x); }
499499

500500
__DEVICE__
501501
float logbf(float __x) { return __ocml_logb_f32(__x); }
502502

503503
__DEVICE__
504-
float logf(float __x) { return __FAST_OR_SLOW(__logf, __ocml_log_f32)(__x); }
504+
float logf(float __x) { return __FAST_OR_SLOW(__logf, __builtin_logf)(__x); }
505505

506506
__DEVICE__
507507
long int lrintf(float __x) { return __builtin_rintf(__x); }

clang/test/Headers/__clang_hip_math.hip

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,6 @@ extern "C" __device__ double test_cospi(double x) {
10751075
return cospi(x);
10761076
}
10771077

1078-
//
10791078
// DEFAULT-LABEL: @test_cyl_bessel_i0f(
10801079
// DEFAULT-NEXT: entry:
10811080
// DEFAULT-NEXT: [[CALL_I:%.*]] = tail call contract noundef float @__ocml_i0_f32(float noundef [[X:%.*]]) #[[ATTR14]]
@@ -1270,23 +1269,23 @@ extern "C" __device__ double test_erfinv(double x) {
12701269

12711270
// DEFAULT-LABEL: @test_exp10f(
12721271
// DEFAULT-NEXT: entry:
1273-
// DEFAULT-NEXT: [[CALL_I:%.*]] = tail call contract noundef float @__ocml_exp10_f32(float noundef [[X:%.*]]) #[[ATTR13]]
1274-
// DEFAULT-NEXT: ret float [[CALL_I]]
1272+
// DEFAULT-NEXT: [[TMP0:%.*]] = tail call contract noundef float @llvm.exp10.f32(float [[X:%.*]])
1273+
// DEFAULT-NEXT: ret float [[TMP0]]
12751274
//
12761275
// FINITEONLY-LABEL: @test_exp10f(
12771276
// FINITEONLY-NEXT: entry:
1278-
// FINITEONLY-NEXT: [[CALL_I:%.*]] = tail call nnan ninf contract noundef nofpclass(nan inf) float @__ocml_exp10_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR13]]
1279-
// FINITEONLY-NEXT: ret float [[CALL_I]]
1277+
// FINITEONLY-NEXT: [[TMP0:%.*]] = tail call nnan ninf contract noundef float @llvm.exp10.f32(float [[X:%.*]])
1278+
// FINITEONLY-NEXT: ret float [[TMP0]]
12801279
//
12811280
// APPROX-LABEL: @test_exp10f(
12821281
// APPROX-NEXT: entry:
1283-
// APPROX-NEXT: [[CALL_I:%.*]] = tail call contract noundef float @__ocml_exp10_f32(float noundef [[X:%.*]]) #[[ATTR13]]
1284-
// APPROX-NEXT: ret float [[CALL_I]]
1282+
// APPROX-NEXT: [[TMP0:%.*]] = tail call contract noundef float @llvm.exp10.f32(float [[X:%.*]])
1283+
// APPROX-NEXT: ret float [[TMP0]]
12851284
//
12861285
// AMDGCNSPIRV-LABEL: @test_exp10f(
12871286
// AMDGCNSPIRV-NEXT: entry:
1288-
// AMDGCNSPIRV-NEXT: [[CALL_I:%.*]] = tail call contract spir_func noundef addrspace(4) float @__ocml_exp10_f32(float noundef [[X:%.*]]) #[[ATTR13]]
1289-
// AMDGCNSPIRV-NEXT: ret float [[CALL_I]]
1287+
// AMDGCNSPIRV-NEXT: [[TMP0:%.*]] = tail call contract noundef addrspace(4) float @llvm.exp10.f32(float [[X:%.*]])
1288+
// AMDGCNSPIRV-NEXT: ret float [[TMP0]]
12901289
//
12911290
extern "C" __device__ float test_exp10f(float x) {
12921291
return exp10f(x);
@@ -1748,7 +1747,6 @@ extern "C" __device__ double test_fmax(double x, double y) {
17481747
return fmax(x, y);
17491748
}
17501749

1751-
//
17521750
// DEFAULT-LABEL: @test_fminf(
17531751
// DEFAULT-NEXT: entry:
17541752
// DEFAULT-NEXT: [[TMP0:%.*]] = tail call contract noundef float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
@@ -2823,13 +2821,13 @@ extern "C" __device__ double test_log1p(double x) {
28232821

28242822
// DEFAULT-LABEL: @test_log2f(
28252823
// DEFAULT-NEXT: entry:
2826-
// DEFAULT-NEXT: [[CALL_I:%.*]] = tail call contract noundef float @__ocml_log2_f32(float noundef [[X:%.*]]) #[[ATTR13]]
2827-
// DEFAULT-NEXT: ret float [[CALL_I]]
2824+
// DEFAULT-NEXT: [[TMP0:%.*]] = tail call contract noundef float @llvm.log2.f32(float [[X:%.*]])
2825+
// DEFAULT-NEXT: ret float [[TMP0]]
28282826
//
28292827
// FINITEONLY-LABEL: @test_log2f(
28302828
// FINITEONLY-NEXT: entry:
2831-
// FINITEONLY-NEXT: [[CALL_I:%.*]] = tail call nnan ninf contract noundef nofpclass(nan inf) float @__ocml_log2_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR13]]
2832-
// FINITEONLY-NEXT: ret float [[CALL_I]]
2829+
// FINITEONLY-NEXT: [[TMP0:%.*]] = tail call nnan ninf contract noundef float @llvm.log2.f32(float [[X:%.*]])
2830+
// FINITEONLY-NEXT: ret float [[TMP0]]
28332831
//
28342832
// APPROX-LABEL: @test_log2f(
28352833
// APPROX-NEXT: entry:
@@ -2838,8 +2836,8 @@ extern "C" __device__ double test_log1p(double x) {
28382836
//
28392837
// AMDGCNSPIRV-LABEL: @test_log2f(
28402838
// AMDGCNSPIRV-NEXT: entry:
2841-
// AMDGCNSPIRV-NEXT: [[CALL_I:%.*]] = tail call contract spir_func noundef addrspace(4) float @__ocml_log2_f32(float noundef [[X:%.*]]) #[[ATTR13]]
2842-
// AMDGCNSPIRV-NEXT: ret float [[CALL_I]]
2839+
// AMDGCNSPIRV-NEXT: [[TMP0:%.*]] = tail call contract noundef addrspace(4) float @llvm.log2.f32(float [[X:%.*]])
2840+
// AMDGCNSPIRV-NEXT: ret float [[TMP0]]
28432841
//
28442842
extern "C" __device__ float test_log2f(float x) {
28452843
return log2f(x);
@@ -2919,13 +2917,13 @@ extern "C" __device__ double test_logb(double x) {
29192917

29202918
// DEFAULT-LABEL: @test_logf(
29212919
// DEFAULT-NEXT: entry:
2922-
// DEFAULT-NEXT: [[CALL_I:%.*]] = tail call contract noundef float @__ocml_log_f32(float noundef [[X:%.*]]) #[[ATTR13]]
2923-
// DEFAULT-NEXT: ret float [[CALL_I]]
2920+
// DEFAULT-NEXT: [[TMP0:%.*]] = tail call contract noundef float @llvm.log.f32(float [[X:%.*]])
2921+
// DEFAULT-NEXT: ret float [[TMP0]]
29242922
//
29252923
// FINITEONLY-LABEL: @test_logf(
29262924
// FINITEONLY-NEXT: entry:
2927-
// FINITEONLY-NEXT: [[CALL_I:%.*]] = tail call nnan ninf contract noundef nofpclass(nan inf) float @__ocml_log_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR13]]
2928-
// FINITEONLY-NEXT: ret float [[CALL_I]]
2925+
// FINITEONLY-NEXT: [[TMP0:%.*]] = tail call nnan ninf contract noundef float @llvm.log.f32(float [[X:%.*]])
2926+
// FINITEONLY-NEXT: ret float [[TMP0]]
29292927
//
29302928
// APPROX-LABEL: @test_logf(
29312929
// APPROX-NEXT: entry:
@@ -2934,8 +2932,8 @@ extern "C" __device__ double test_logb(double x) {
29342932
//
29352933
// AMDGCNSPIRV-LABEL: @test_logf(
29362934
// AMDGCNSPIRV-NEXT: entry:
2937-
// AMDGCNSPIRV-NEXT: [[CALL_I:%.*]] = tail call contract spir_func noundef addrspace(4) float @__ocml_log_f32(float noundef [[X:%.*]]) #[[ATTR13]]
2938-
// AMDGCNSPIRV-NEXT: ret float [[CALL_I]]
2935+
// AMDGCNSPIRV-NEXT: [[TMP0:%.*]] = tail call contract noundef addrspace(4) float @llvm.log.f32(float [[X:%.*]])
2936+
// AMDGCNSPIRV-NEXT: ret float [[TMP0]]
29392937
//
29402938
extern "C" __device__ float test_logf(float x) {
29412939
return logf(x);

0 commit comments

Comments
 (0)