aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-10-27 12:00:34 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-10-27 12:00:34 +0000
commit86c0733fed7007dd41efe7739c8295e9933e7f98 (patch)
treef5961b5f8cf96e4f45f558ac49d191d07d4d090a /gcc/builtins.c
parent83668c858e5d0ee47a21d5a855b56b9f4ca2d93a (diff)
downloadgcc-86c0733fed7007dd41efe7739c8295e9933e7f98.zip
gcc-86c0733fed7007dd41efe7739c8295e9933e7f98.tar.gz
gcc-86c0733fed7007dd41efe7739c8295e9933e7f98.tar.bz2
Move ldexp, scalbn and scalbln folds to match.pd
Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * builtins.c (fold_builtin_load_exponent): Rename to... (fold_const_builtin_load_exponent): ...this and only handle constant arguments. (fold_builtin_2): Update accordingly. * match.pd: Add rules previously handled by fold_builtin_load_exponent. gcc/testsuite/ * gcc.dg/torture/builtin-ldexp-1.c: Skip at -O9, From-SVN: r229434
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 260b66d..248c009 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8060,20 +8060,11 @@ fold_builtin_frexp (location_t loc, tree arg0, tree arg1, tree rettype)
check the mode of the TYPE parameter in certain cases. */
static tree
-fold_builtin_load_exponent (location_t loc, tree arg0, tree arg1,
- tree type, bool ldexp)
+fold_const_builtin_load_exponent (tree arg0, tree arg1,
+ tree type, bool ldexp)
{
if (validate_arg (arg0, REAL_TYPE) && validate_arg (arg1, INTEGER_TYPE))
{
- STRIP_NOPS (arg0);
- STRIP_NOPS (arg1);
-
- /* If arg0 is 0, Inf or NaN, or if arg1 is 0, then return arg0. */
- if (real_zerop (arg0) || integer_zerop (arg1)
- || (TREE_CODE (arg0) == REAL_CST
- && !real_isfinite (&TREE_REAL_CST (arg0))))
- return omit_one_operand_loc (loc, type, arg0, arg1);
-
/* If both arguments are constant, then try to evaluate it. */
if ((ldexp || REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2)
&& TREE_CODE (arg0) == REAL_CST && !TREE_OVERFLOW (arg0)
@@ -9126,11 +9117,12 @@ fold_builtin_2 (location_t loc, tree fndecl, tree arg0, tree arg1)
break;
CASE_FLT_FN (BUILT_IN_LDEXP):
- return fold_builtin_load_exponent (loc, arg0, arg1, type, /*ldexp=*/true);
+ return fold_const_builtin_load_exponent (arg0, arg1, type,
+ /*ldexp=*/true);
CASE_FLT_FN (BUILT_IN_SCALBN):
CASE_FLT_FN (BUILT_IN_SCALBLN):
- return fold_builtin_load_exponent (loc, arg0, arg1,
- type, /*ldexp=*/false);
+ return fold_const_builtin_load_exponent (arg0, arg1, type,
+ /*ldexp=*/false);
CASE_FLT_FN (BUILT_IN_FREXP):
return fold_builtin_frexp (loc, arg0, arg1, type);