]> granicus.if.org Git - clang/commitdiff
Make ceil/floor/nearbyint/rint/round const even with -fmath-errno.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 22 Aug 2012 18:50:01 +0000 (18:50 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 22 Aug 2012 18:50:01 +0000 (18:50 +0000)
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

include/clang/Basic/Builtins.def
test/CodeGen/libcall-declarations.c

index 9c487ae5994cb33dbe1d7c0e0ddac393c8f5152d..13205e9f91f183c83120dbb50241c628bc3bfb3f 100644 (file)
@@ -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)
index 46a024a3416e018e50a14df7971946c148c97c6c..4517643e4c4ed3ce19e55376d1baa69e198b384a 100644 (file)
@@ -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