fold-const.c (fold <ABS_EXPR>): Re-fold the result of folding fabs(-x) into fabs(x).
authorRoger Sayle <sayle@gcc.gnu.org>
Fri, 6 Jun 2003 12:36:26 +0000 (12:36 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Fri, 6 Jun 2003 12:36:26 +0000 (12:36 +0000)
commit07bae5ad21964fd180a8f85e300cf823dfa04b53
tree853d13ba808d4dc5f75ea461cff59feb4787b64b
parent84cd52a9a95c0737455364222901afb418f7c345
fold-const.c (fold <ABS_EXPR>): Re-fold the result of folding fabs(-x) into fabs(x).

* fold-const.c (fold <ABS_EXPR>):  Re-fold the result of folding
fabs(-x) into fabs(x).  Use tree_expr_nonnegative_p to determine
when the ABS_EXPR (fabs or abs) is not required.
   (tree_expr_nonnegative_p): Move the logic that sqrt and exp are
always nonnegative from fold to here.  Additionally, cabs and fabs
are always non-negative, and pow and atan are non-negative if
their first argument is non-negative.

* builtins.c (fold_builtin_cabs): New function to fold cabs{,f,l}.
Evaluate cabs of a constant at compile-time.  Convert cabs of a
non-complex argument into fabs.  Convert cabs(z) into
sqrt(z.r*z.r + z.i*z.i) at the tree-level with -ffast-math or
-funsafe-math-optimizations or -ffast-math.
(fold_builtin): Convert BUILT_IN_FABS{,F,L} into an ABS_EXPR.
Fold BUILT_IN_CABS{,F,L} using fold_builtin_cabs.

* gcc.dg/builtins-2.c: Add some more tests.
* gcc.dg/builtins-18.c: New test case.
* gcc.dg/builtins-19.c: New test case.

From-SVN: r67541
gcc/ChangeLog
gcc/builtins.c
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-18.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/builtins-19.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/builtins-2.c