diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-03 21:38:55 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-03 21:38:55 +0000 |
commit | 277f8dd25eda8b28d1f12a4c7426383be5e16e7a (patch) | |
tree | 6f8671ee7d010f3f877a3ed92690c0d270f47544 /gcc/fold-const.c | |
parent | c5e5e7e4cf6b7bd40b8af9ddb92ce11707fdfb6e (diff) | |
download | ppe42-gcc-277f8dd25eda8b28d1f12a4c7426383be5e16e7a.tar.gz ppe42-gcc-277f8dd25eda8b28d1f12a4c7426383be5e16e7a.zip |
* real.c (real_trunc, real_floor, real_ceil): New functions
to implement trunc, floor and ceil respectively.
* real.h (real_trunc, real_floor, real_ceil): Prototype here.
* builtins.c (integer_valued_real_p): New function to test if
a floating point expression has an integer valued result.
(fold_trunc_transparent_mathfn): Optimize foo(foo(x)) as
foo(x) where foo is an integer rounding function. Similarly,
optimize foo(bar(x)) as bar(x), and foo((double)(int)x) as
(double)(int)x when both foo and bar are integer rounding
functions and we don't need to honor errno.
(fold_builtin_trunc, fold_builtin_floor, fold_builtin_ceil):
New functions to fold trunc, floor and ceil.
(fold_builtin): Use fold_builtin_trunc to fold BUILT_IN_TRUNC*,
fold_builtin_floor to fold BUILT_IN_FLOOR* and fold_builtin_ceil
to fold BUILT_IN_CEIL*.
* fold-const.c (tree_expr_nonnegative_p): Handle FLOAT_EXPR and
the remaining integer rounding functions.
* gcc.dg/builtins-25.c: New testcase.
* gcc.dg/builtins-26.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68903 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c4826c784af..0524e1dc16e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8105,6 +8105,8 @@ tree_expr_nonnegative_p (tree t) return tree_expr_nonnegative_p (TREE_OPERAND (t, 0)); case NON_LVALUE_EXPR: return tree_expr_nonnegative_p (TREE_OPERAND (t, 0)); + case FLOAT_EXPR: + return tree_expr_nonnegative_p (TREE_OPERAND (t, 0)); case RTL_EXPR: return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t)); @@ -8141,6 +8143,15 @@ tree_expr_nonnegative_p (tree t) case BUILT_IN_FLOOR: case BUILT_IN_FLOORF: case BUILT_IN_FLOORL: + case BUILT_IN_NEARBYINT: + case BUILT_IN_NEARBYINTF: + case BUILT_IN_NEARBYINTL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: return tree_expr_nonnegative_p (TREE_VALUE (arglist)); case BUILT_IN_POW: |