Skip to content

Commit e7ab698

Browse files
committed
HIP: Directly call nearbyint builtins
1 parent 395cd33 commit e7ab698

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

clang/lib/Headers/__clang_hip_math.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ float nanf(const char *__tagp __attribute__((nonnull))) {
369369
}
370370

371371
__DEVICE__
372-
float nearbyintf(float __x) { return __ocml_nearbyint_f32(__x); }
372+
float nearbyintf(float __x) { return __builtin_nearbyintf(__x); }
373373

374374
__DEVICE__
375375
float nextafterf(float __x, float __y) {
@@ -925,7 +925,7 @@ double nan(const char *__tagp) {
925925
}
926926

927927
__DEVICE__
928-
double nearbyint(double __x) { return __ocml_nearbyint_f64(__x); }
928+
double nearbyint(double __x) { return __builtin_nearbyint(__x); }
929929

930930
__DEVICE__
931931
double nextafter(double __x, double __y) {

clang/test/Headers/__clang_hip_math.hip

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,27 +1996,27 @@ extern "C" __device__ double test_nan_fill() {
19961996

19971997
// DEFAULT-LABEL: @test_nearbyintf(
19981998
// DEFAULT-NEXT: entry:
1999-
// DEFAULT-NEXT: [[CALL_I:%.*]] = tail call contract float @__ocml_nearbyint_f32(float noundef [[X:%.*]]) #[[ATTR14]]
2000-
// DEFAULT-NEXT: ret float [[CALL_I]]
1999+
// DEFAULT-NEXT: [[TMP0:%.*]] = tail call contract float @llvm.nearbyint.f32(float [[X:%.*]])
2000+
// DEFAULT-NEXT: ret float [[TMP0]]
20012001
//
20022002
// FINITEONLY-LABEL: @test_nearbyintf(
20032003
// FINITEONLY-NEXT: entry:
2004-
// FINITEONLY-NEXT: [[CALL_I:%.*]] = tail call nnan ninf contract nofpclass(nan inf) float @__ocml_nearbyint_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
2005-
// FINITEONLY-NEXT: ret float [[CALL_I]]
2004+
// FINITEONLY-NEXT: [[TMP0:%.*]] = tail call nnan ninf contract float @llvm.nearbyint.f32(float [[X:%.*]])
2005+
// FINITEONLY-NEXT: ret float [[TMP0]]
20062006
//
20072007
extern "C" __device__ float test_nearbyintf(float x) {
20082008
return nearbyintf(x);
20092009
}
20102010

20112011
// DEFAULT-LABEL: @test_nearbyint(
20122012
// DEFAULT-NEXT: entry:
2013-
// DEFAULT-NEXT: [[CALL_I:%.*]] = tail call contract double @__ocml_nearbyint_f64(double noundef [[X:%.*]]) #[[ATTR14]]
2014-
// DEFAULT-NEXT: ret double [[CALL_I]]
2013+
// DEFAULT-NEXT: [[TMP0:%.*]] = tail call contract double @llvm.nearbyint.f64(double [[X:%.*]])
2014+
// DEFAULT-NEXT: ret double [[TMP0]]
20152015
//
20162016
// FINITEONLY-LABEL: @test_nearbyint(
20172017
// FINITEONLY-NEXT: entry:
2018-
// FINITEONLY-NEXT: [[CALL_I:%.*]] = tail call nnan ninf contract nofpclass(nan inf) double @__ocml_nearbyint_f64(double noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
2019-
// FINITEONLY-NEXT: ret double [[CALL_I]]
2018+
// FINITEONLY-NEXT: [[TMP0:%.*]] = tail call nnan ninf contract double @llvm.nearbyint.f64(double [[X:%.*]])
2019+
// FINITEONLY-NEXT: ret double [[TMP0]]
20202020
//
20212021
extern "C" __device__ double test_nearbyint(double x) {
20222022
return nearbyint(x);

0 commit comments

Comments
 (0)