From f1b844c6875a70e9735ca083a3d46c722445022e Mon Sep 17 00:00:00 2001 From: sayle Date: Tue, 24 Jun 2003 02:20:12 +0000 Subject: * 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 --- gcc/testsuite/gcc.dg/builtins-24.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/builtins-24.c (limited to 'gcc/testsuite/gcc.dg/builtins-24.c') 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; +} + -- cgit v1.2.1