summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/builtins-24.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-24 02:20:12 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-24 02:20:12 +0000
commitf1b844c6875a70e9735ca083a3d46c722445022e (patch)
treee544613227ec08f4df55e0c085a0efa4b3b4352b /gcc/testsuite/gcc.dg/builtins-24.c
parent11d0d1694bc2f2b71dc4056250c5034e3eb8db7d (diff)
downloadgcc-f1b844c6875a70e9735ca083a3d46c722445022e.tar.gz
* builtins.c (expand_builtin): Use expand_builtin_pow to expand
calls for pow, powf, powl and their __builtin_ variants. (expand_builtin_pow): If the second argument is a constant integer and compiling with -ffast-math, use expand_powi to generate RTL if powi_cost is less than POWI_MAX_MULTS. (powi_cost): New function to return the number of multiplications necessary to evaluate an Nth power, for integer constant N. (expand_powi): New function to expand the RTL for evaluating the Nth power of a floating point value, for integer constant N. * doc/tm.texi (POWI_MAX_MULTS): Document new target macro. * gcc.dg/builtins-24.c: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68401 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/builtins-24.c')
-rw-r--r--gcc/testsuite/gcc.dg/builtins-24.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/builtins-24.c b/gcc/testsuite/gcc.dg/builtins-24.c
new file mode 100644
index 00000000000..41ec1889f5f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-24.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Check that the RTL expansion of floating point exponentiation by
+ a constant integer doesn't break anything and produces the expected
+ results.
+
+ Written by Roger Sayle, 20th June 2003. */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern double pow(double,double);
+extern void abort(void);
+
+double foo (double x)
+{
+ return pow (x, 6);
+}
+
+double bar (double x)
+{
+ return pow (x, -4);
+}
+
+int main()
+{
+ if (foo (2.0) != 64.0)
+ abort ();
+
+ if (bar (2.0) != 0.0625)
+ abort ();
+
+ return 0;
+}
+