Make ceil/floor/nearbyint/rint/round const even with -fmath-errno.

The conditions described by POSIX can never happen with IEEE-754 floats.
When the function is const we can emit a single sse4.1 instruction for
it, without losing anything :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2012-08-22 18:50:01 +00:00
Родитель 5c1dcc5975
Коммит a148fbcb5f
2 изменённых файлов: 31 добавлений и 16 удалений

Просмотреть файл

@ -826,9 +826,9 @@ LIBBUILTIN(atan2, "ddd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(atan2l, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(atan2f, "fff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceil, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceill, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceilf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceil, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceill, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceilf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysign, "ddd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysignl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
@ -850,9 +850,9 @@ LIBBUILTIN(fabs, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabsl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabsf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floor, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floor, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fma, "dddd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmal, "LdLdLdLd", "fc", "math.h", ALL_LANGUAGES)
@ -874,21 +874,21 @@ LIBBUILTIN(log2, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2l, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2f, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyint, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyint, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(pow, "ddd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(powl, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(powf, "fff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rint, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rint, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(round, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(round, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sin, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sinl, "LdLd", "fe", "math.h", ALL_LANGUAGES)

Просмотреть файл

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=CHECK-NOERRNO
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -o - -emit-llvm %s | FileCheck %s -check-prefix=CHECK-ERRNO
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=CHECK-ERRNO
// Prototypes.
double acos(double);
@ -159,18 +159,33 @@ void *use[] = {
// CHECK-NOERRNO: declare x86_fp80 @truncl(x86_fp80) nounwind readnone
// CHECK-NOERRNO: declare float @truncf(float) nounwind readnone
// CHECK-ERRNO: declare double @ceil(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @ceill(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @ceilf(float) nounwind readnone
// CHECK-ERRNO: declare double @copysign(double, double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @copysignl(x86_fp80, x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @copysignf(float, float) nounwind readnone
// CHECK-ERRNO: declare double @fabs(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @fabsl(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @fabsf(float) nounwind readnone
// CHECK-ERRNO: declare double @floor(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @floorl(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @floorf(float) nounwind readnone
// CHECK-ERRNO: declare double @fmax(double, double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @fmaxl(x86_fp80, x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @fmaxf(float, float) nounwind readnone
// CHECK-ERRNO: declare double @fmin(double, double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @fminf(float, float) nounwind readnone
// CHECK-ERRNO: declare double @nearbyint(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @nearbyintf(float) nounwind readnone
// CHECK-ERRNO: declare double @rint(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @rintl(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @rintf(float) nounwind readnone
// CHECK-ERRNO: declare double @round(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @roundl(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @roundf(float) nounwind readnone
// CHECK-ERRNO: declare double @trunc(double) nounwind readnone
// CHECK-ERRNO: declare x86_fp80 @truncl(x86_fp80) nounwind readnone
// CHECK-ERRNO: declare float @truncf(float) nounwind readnone