[cfe-commits] r162379 - in /cfe/trunk: include/clang/Basic/Builtins.def test/CodeGen/libcall-declarations.c

Benjamin Kramer benny.kra at googlemail.com
Wed Aug 22 11:50:02 PDT 2012


Author: d0k
Date: Wed Aug 22 13:50:01 2012
New Revision: 162379

URL: http://llvm.org/viewvc/llvm-project?rev=162379&view=rev
Log:
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 :)

Modified:
    cfe/trunk/include/clang/Basic/Builtins.def
    cfe/trunk/test/CodeGen/libcall-declarations.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=162379&r1=162378&r2=162379&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Aug 22 13:50:01 2012
@@ -826,9 +826,9 @@
 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(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(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(round, "dd", "fe", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(roundl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(roundf, "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", "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)

Modified: cfe/trunk/test/CodeGen/libcall-declarations.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcall-declarations.c?rev=162379&r1=162378&r2=162379&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/libcall-declarations.c (original)
+++ cfe/trunk/test/CodeGen/libcall-declarations.c Wed Aug 22 13:50:01 2012
@@ -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 @@
 // 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





More information about the cfe-commits mailing list