calls.c (expand_call): Recognize calls to "sqrt" and create corresponding notes.
authorMark Mitchell <mark@codesourcery.com>
Wed, 24 Dec 2003 06:52:27 +0000 (06:52 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 24 Dec 2003 06:52:27 +0000 (06:52 +0000)
* calls.c (expand_call): Recognize calls to "sqrt" and create
corresponding notes.

* g++.dg/bprob/bprob.exp: Load target-supports.exp
* g77.dg/bprob/bprob.exp: Likewise.
* gcc.misc-tests/bprob.exp: Likewise.
* gcc.dg/builtins-18.c: Use builtins-config.h.  Do not test float
variants on systems where the library does not provide that
functionality.
* gcc.dg/builtins-20.c: Use builtins-config.h.
* gcc.dg/builtins-config.h: New file.

From-SVN: r75003

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/bprob/bprob.exp
gcc/testsuite/g77.dg/bprob/bprob.exp
gcc/testsuite/gcc.dg/builtins-18.c
gcc/testsuite/gcc.dg/builtins-20.c
gcc/testsuite/gcc.dg/builtins-config.h [new file with mode: 0644]
gcc/testsuite/gcc.misc-tests/bprob.exp

index 10dd567..f1e24bc 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-23  Mark Mitchell  <mark@codesourcery.com>
+
+       * calls.c (expand_call): Recognize calls to "sqrt" and create
+       corresponding notes.
+
 2003-12-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * config/mips/mips.c (override_options): Use `inform' instead
index e589de1..d9a62e7 100644 (file)
@@ -3150,22 +3150,33 @@ expand_call (tree exp, rtx target, int ignore)
                mark_reg_pointer (temp,
                                  TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp))));
 
-             /* Construct an "equal form" for the value which mentions all the
-                arguments in order as well as the function name.  */
-             for (i = 0; i < num_actuals; i++)
-               note = gen_rtx_EXPR_LIST (VOIDmode,
-                                         args[i].initial_value, note);
-             note = gen_rtx_EXPR_LIST (VOIDmode, funexp, note);
-
              end_sequence ();
-
-             if (flags & ECF_PURE)
-               note = gen_rtx_EXPR_LIST (VOIDmode,
+             if (flag_unsafe_math_optimizations
+                 && fndecl
+                 && DECL_BUILT_IN (fndecl)
+                 && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRT
+                     || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRTF
+                     || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRTL))
+               note = gen_rtx_fmt_e (SQRT, 
+                                     GET_MODE (temp), 
+                                     args[0].initial_value);
+             else
+               {
+                 /* Construct an "equal form" for the value which
+                    mentions all the arguments in order as well as
+                    the function name.  */
+                 for (i = 0; i < num_actuals; i++)
+                   note = gen_rtx_EXPR_LIST (VOIDmode,
+                                             args[i].initial_value, note);
+                 note = gen_rtx_EXPR_LIST (VOIDmode, funexp, note);
+                 
+                 if (flags & ECF_PURE)
+                   note = gen_rtx_EXPR_LIST (VOIDmode,
                        gen_rtx_USE (VOIDmode,
                                     gen_rtx_MEM (BLKmode,
                                                  gen_rtx_SCRATCH (VOIDmode))),
                        note);
-
+               }
              emit_libcall_block (insns, temp, valreg, note);
 
              valreg = temp;
index f1558a7..e0086f4 100644 (file)
@@ -1,5 +1,16 @@
 2003-12-23  Mark Mitchell  <mark@codesourcery.com>
 
+       * g++.dg/bprob/bprob.exp: Load target-supports.exp
+       * g77.dg/bprob/bprob.exp: Likewise.
+       * gcc.misc-tests/bprob.exp: Likewise.
+       * gcc.dg/builtins-18.c: Use builtins-config.h.  Do not test float
+       variants on systems where the library does not provide that
+       functionality.
+       * gcc.dg/builtins-20.c: Use builtins-config.h.
+       * gcc.dg/builtins-config.h: New file.
+
+2003-12-23  Mark Mitchell  <mark@codesourcery.com>
+
        * lib/gcc-dg.exp (dg-require-profiling): New function.
        * lib/target-supports.exp (check_profiling_available): Likewise.
        * g++.dg/bprob/bprob.exp: Use check_profiling_available.
index 35bec33..bef5783 100644 (file)
@@ -17,6 +17,8 @@
 # Test the functionality of programs compiled with profile-directed block
 # ordering using -fprofile-arcs followed by -fbranch-probabilities.
 
+load_lib target-supports.exp
+
 # Some targets don't have any implementation of __bb_init_func or are
 # missing other needed machinery.
 if { ![check_profiling_available] } {
index e30234e..6eb45be 100644 (file)
@@ -17,6 +17,8 @@
 # Test the functionality of programs compiled with profile-directed block
 # ordering using -fprofile-arcs followed by -fbranch-probabilities.
 
+load_lib target-supports.exp
+
 # Some targets don't have any implementation of __bb_init_func or are
 # missing other needed machinery.
 if { ![check_profiling_available] } {
index 07b9418..a47de8b 100644 (file)
@@ -8,11 +8,7 @@
 /* { dg-do link } */
 /* { dg-options "-O2 -ffast-math" } */
 
-
-/* Solaris doesn't have the entire C99 runtime.  */
-#if !defined(sun)
-#define HAVE_C99_RUNTIME
-#endif
+#include "builtins-config.h"
 
 extern void link_error(void);
 
@@ -29,6 +25,7 @@ main (void)
   double _Complex dc = 3.0 + 4.0i;
   long double _Complex ldc = 3.0L + 4.0iL;
 
+#ifdef HAVE_C99_RUNTIME
   /* Test floats.  */
   if (cabsf (fc) != 5.0F)
     link_error ();
@@ -38,6 +35,7 @@ main (void)
     link_failure ();
   if (__builtin_cabsf (3.0F + 4.0iF) != 5.0F)
     link_failure ();
+#endif
 
   /* Test doubles.  */
   if (cabs (dc) != 5.0)
index b633c55..1bd9534 100644 (file)
@@ -8,11 +8,7 @@
 /* { dg-do link } */
 /* { dg-options "-O2 -ffast-math" } */
 
-
-/* Solaris doesn't have the entire C99 runtime.  */
-#if !defined(sun)
-#define HAVE_C99_RUNTIME
-#endif
+#include "builtins-config.h"
 
 extern void link_error(void);
 
diff --git a/gcc/testsuite/gcc.dg/builtins-config.h b/gcc/testsuite/gcc.dg/builtins-config.h
new file mode 100644 (file)
index 0000000..11f7c11
--- /dev/null
@@ -0,0 +1,29 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+   Define macros useful in tests for bulitin functions.  */
+
+/* Define HAVE_C99_RUNTIME if the entire C99 runtime is available on
+   the target system.  The value of HAVE_C99_RUNTIME should be the
+   same as the value of TARGET_C99_FUNCTIONS in the GCC machine
+   description.  (Perhaps GCC should predefine a special macro
+   indicating whether or not TARGET_C99_FUNCTIONS is set, but it does
+   not presently do that.)  */
+
+#if defined(sun)
+/* Solaris doesn't have the entire C99 runtime.  */
+#else
+/* Newlib has the "f" variants of the math functions, but not the "l"
+   variants.  TARGET_C99_FUNCTIONS is only defined if all C99
+   functions are present.  Therefore, on systems using newlib, tests
+   of builtins will fail for both the "f" and the "l" variants, and we
+   should therefore not define HAVE_C99_RUNTIME.  Including <limits.h>
+   gives us a way of seeing if _NEWLIB_VERSION is defined.  Include
+   <math.h> would work too, but the GLIBC math inlines cause us to
+   generate inferior code, which causes the test to fail, so it is
+   not safe to include <math.h>.  */
+#include <limits.h>
+#ifdef _NEWLIB_VERSION
+#else
+#define HAVE_C99_RUNTIME
+#endif
+#endif
index df59900..5afbdb1 100644 (file)
@@ -17,6 +17,8 @@
 # Test the functionality of programs compiled with profile-directed block
 # ordering using -fprofile-arcs followed by -fbranch-probabilities.
 
+load_lib target-supports.exp
+
 # Some targets don't have any implementation of __bb_init_func or are
 # missing other needed machinery.
 if { ![check_profiling_available] } {