From 73463c5e847ca23a8f51ef5b8ad8a19c99696799 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 5 Oct 2015 13:37:15 +0000 Subject: Add a build_real_truncate helper function ...which simplifies the match.pd patterns I'm about to add. Bootstrapped & regression-tested on x86_64-linux-gnu. gcc/ * real.h (build_real_truncate): Declare. * tree.c (build_real_truncate): New function. (strip_float_extensions): Use it. * builtins.c (fold_builtin_cabs, fold_builtin_sqrt, fold_builtin_cbrt) (fold_builtin_hypot, fold_builtin_pow): Likewise. * match.pd: Likewise. From-SVN: r228483 --- gcc/tree.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index bfcf374..f78a2c2 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1877,6 +1877,14 @@ build_real (tree type, REAL_VALUE_TYPE d) return v; } +/* Like build_real, but first truncate D to the type. */ + +tree +build_real_truncate (tree type, REAL_VALUE_TYPE d) +{ + return build_real (type, real_value_truncate (TYPE_MODE (type), d)); +} + /* Return a new REAL_CST node whose type is TYPE and whose value is the integer value of the INTEGER_CST node I. */ @@ -12093,7 +12101,7 @@ strip_float_extensions (tree exp) && exact_real_truncate (TYPE_MODE (double_type_node), &orig)) type = double_type_node; if (type) - return build_real (type, real_value_truncate (TYPE_MODE (type), orig)); + return build_real_truncate (type, orig); } if (!CONVERT_EXPR_P (exp)) -- cgit v1.1