From 277f8dd25eda8b28d1f12a4c7426383be5e16e7a Mon Sep 17 00:00:00 2001 From: sayle Date: Thu, 3 Jul 2003 21:38:55 +0000 Subject: * 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 --- gcc/real.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/real.h') diff --git a/gcc/real.h b/gcc/real.h index 71e3cc4b6b9..fcd7ae7f155 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -375,4 +375,15 @@ extern bool real_powi PARAMS ((REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, HOST_WIDE_INT)); +/* Standard round to integer value functions. */ +extern void real_trunc PARAMS ((REAL_VALUE_TYPE *, + enum machine_mode, + const REAL_VALUE_TYPE *)); +extern void real_floor PARAMS ((REAL_VALUE_TYPE *, + enum machine_mode, + const REAL_VALUE_TYPE *)); +extern void real_ceil PARAMS ((REAL_VALUE_TYPE *, + enum machine_mode, + const REAL_VALUE_TYPE *)); + #endif /* ! GCC_REAL_H */ -- cgit v1.2.1