From 624d31fe0135b7b33529f4e8fae88a4877bfc204 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 5 Oct 2015 11:29:35 +0000 Subject: [PATCH] Replace REAL_VALUES_EQUAL with real_equal Richard B suggested we should replace dconsthalf etc. with dconst<1, 2> (). When I tried that, the extra comma caused problems with some lingering uses of the old target macros for handling reals (e.g. REAL_ARITHMETIC instead of real_arithmetic), since the constant was then treated as two macro parameters. It would have been possible to add an extra level of brackets to avoid this, but I thought I might as well take the opportunity to remove the macros instead. (Note that I'm only removing macros that caused a problem directly, or are closely related to ones that did.) This first patch replaces REAL_VALUES_EQUAL with a real_equal function. The prototype is the same as for real_identical, which has already undergone a half-transition in this direction. Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested by building one target per CPU directory and checking that there were no new warnings and no changes in testsuite output at -O2. gcc/c-family/ * c-lex.c (interpret_float): Use real_equal instead of REAL_VALUES_EQUAL. gcc/c/ * c-typeck.c (c_tree_equal): Use real_equal instead of REAL_VALUES_EQUAL. gcc/cp/ * tree.c (cp_tree_equal): Use real_equal instead of REAL_VALUES_EQUAL. gcc/ * real.h (real_equal): Declare. (REAL_VALUES_EQUAL): Delete. * real.c (real_equal): New function. (real_compare): Use it. * doc/tm.texi.in (REAL_VALUES_EQUAL): Delete. * doc/tm.texi: Regenerate. * builtins.c (fold_builtin_pow, fold_builtin_load_exponent): Use real_equal instead of REAL_VALUES_EQUAL. * config/aarch64/aarch64.c (aarch64_float_const_zero_rtx_p): Likewise. * config/arm/arm.c (arm_const_double_rtx, neon_valid_immediate) (fp_const_from_val): Likewise. * config/fr30/fr30.c (fr30_const_double_is_zero): Likewise. * config/m68k/m68k.c (standard_68881_constant_p): Likewise. (floating_exact_log2): Likewise. * config/sh/sh.c (fp_zero_operand, fp_one_operand): Likewise. * config/vax/vax.c (vax_float_literal): Likewise. * config/xtensa/predicates.md (const_float_1_operand): Likewise. * cprop.c (implicit_set_cond_p): Likewise. * expmed.c (expand_mult): Likewise. * fold-const.c (const_binop): Likewise. * simplify-rtx.c (simplify_binary_operation_1): Likewise. (simplify_const_binary_operation): Likewise. (simplify_const_relational_operation): Likewise. * tree-call-cdce.c (check_pow): Likewise. (gen_conditions_for_pow_cst_base): Likewise. * tree-inline.c (estimate_num_insns): Likewise. * tree-ssa-dom.c (record_equality): Likewise. * tree-ssa-math-opts.c (representable_as_half_series_p): Likewise. (gimple_expand_builtin_pow): Likewise. (pass_optimize_widening_mul::execute): Likewise. * tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise. * tree-vect-patterns.c (vect_recog_pow_pattern): Likewise. * tree.c (real_zerop, real_onep, real_minus_onep): Likewise. --- gcc/builtins.c | 14 +++++++------- gcc/c-family/c-lex.c | 6 +++--- gcc/c/c-typeck.c | 2 +- gcc/config/aarch64/aarch64.c | 2 +- gcc/config/arm/arm.c | 6 +++--- gcc/config/fr30/fr30.c | 2 +- gcc/config/m68k/m68k.c | 6 +++--- gcc/config/sh/sh.c | 4 ++-- gcc/config/vax/vax.c | 4 ++-- gcc/config/xtensa/predicates.md | 2 +- gcc/cp/tree.c | 2 +- gcc/cprop.c | 2 +- gcc/doc/tm.texi | 7 ------- gcc/doc/tm.texi.in | 7 ------- gcc/expmed.c | 2 +- gcc/fold-const.c | 2 +- gcc/real.c | 10 +++++++++- gcc/real.h | 4 ++-- gcc/simplify-rtx.c | 16 ++++++++-------- gcc/tree-call-cdce.c | 4 ++-- gcc/tree-inline.c | 5 +++-- gcc/tree-ssa-dom.c | 2 +- gcc/tree-ssa-math-opts.c | 16 ++++++++-------- gcc/tree-ssa-uncprop.c | 2 +- gcc/tree-vect-patterns.c | 4 ++-- gcc/tree.c | 6 +++--- 26 files changed, 67 insertions(+), 72 deletions(-) From-SVN: r228473 --- gcc/ChangeLog | 64 +++++++++++++++++++++++++++++++++ gcc/builtins.c | 14 ++++---- gcc/c-family/ChangeLog | 5 +++ gcc/c-family/c-lex.c | 6 ++-- gcc/c/ChangeLog | 5 +++ gcc/c/c-typeck.c | 2 +- gcc/config/aarch64/aarch64.c | 2 +- gcc/config/arm/arm.c | 6 ++-- gcc/config/fr30/fr30.c | 2 +- gcc/config/m68k/m68k.c | 6 ++-- gcc/config/sh/sh.c | 4 +-- gcc/config/vax/vax.c | 4 +-- gcc/config/xtensa/predicates.md | 2 +- gcc/cp/ChangeLog | 5 +++ gcc/cp/tree.c | 2 +- gcc/cprop.c | 2 +- gcc/doc/tm.texi | 7 ---- gcc/doc/tm.texi.in | 7 ---- gcc/expmed.c | 2 +- gcc/fold-const.c | 2 +- gcc/real.c | 10 +++++- gcc/real.h | 4 +-- gcc/simplify-rtx.c | 16 ++++----- gcc/tree-call-cdce.c | 4 +-- gcc/tree-inline.c | 5 +-- gcc/tree-ssa-dom.c | 2 +- gcc/tree-ssa-math-opts.c | 16 ++++----- gcc/tree-ssa-uncprop.c | 2 +- gcc/tree-vect-patterns.c | 4 +-- gcc/tree.c | 6 ++-- 30 files changed, 146 insertions(+), 72 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8ab25f2663..8089fb029dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,67 @@ +2015-10-05 Richard Sandiford + + * real.h (real_equal): Declare. + (REAL_VALUES_EQUAL): Delete. + * real.c (real_equal): New function. + (real_compare): Use it. + * doc/tm.texi.in (REAL_VALUES_EQUAL): Delete. + * doc/tm.texi: Regenerate. + * builtins.c (fold_builtin_pow, fold_builtin_load_exponent): Use + real_equal instead of REAL_VALUES_EQUAL. + * config/aarch64/aarch64.c (aarch64_float_const_zero_rtx_p): Likewise. + * config/arm/arm.c (arm_const_double_rtx, neon_valid_immediate) + (fp_const_from_val): Likewise. + * config/fr30/fr30.c (fr30_const_double_is_zero): Likewise. + * config/m68k/m68k.c (standard_68881_constant_p): Likewise. + (floating_exact_log2): Likewise. + * config/sh/sh.c (fp_zero_operand, fp_one_operand): Likewise. + * config/vax/vax.c (vax_float_literal): Likewise. + * config/xtensa/predicates.md (const_float_1_operand): Likewise. + * cprop.c (implicit_set_cond_p): Likewise. + * expmed.c (expand_mult): Likewise. + * fold-const.c (const_binop): Likewise. + * simplify-rtx.c (simplify_binary_operation_1): Likewise. + (simplify_const_binary_operation): Likewise. + (simplify_const_relational_operation): Likewise. + * tree-call-cdce.c (check_pow): Likewise. + (gen_conditions_for_pow_cst_base): Likewise. + * tree-inline.c (estimate_num_insns): Likewise. + * tree-ssa-dom.c (record_equality): Likewise. + * tree-ssa-math-opts.c (representable_as_half_series_p): Likewise. + (gimple_expand_builtin_pow): Likewise. + (pass_optimize_widening_mul::execute): Likewise. + * tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise. + * tree-vect-patterns.c (vect_recog_pow_pattern): Likewise. + * tree.c (real_zerop, real_onep, real_minus_onep): Likewise. +--- + gcc/builtins.c | 14 +++++++------- + gcc/c-family/c-lex.c | 6 +++--- + gcc/c/c-typeck.c | 2 +- + gcc/config/aarch64/aarch64.c | 2 +- + gcc/config/arm/arm.c | 6 +++--- + gcc/config/fr30/fr30.c | 2 +- + gcc/config/m68k/m68k.c | 6 +++--- + gcc/config/sh/sh.c | 4 ++-- + gcc/config/vax/vax.c | 4 ++-- + gcc/config/xtensa/predicates.md | 2 +- + gcc/cp/tree.c | 2 +- + gcc/cprop.c | 2 +- + gcc/doc/tm.texi | 7 ------- + gcc/doc/tm.texi.in | 7 ------- + gcc/expmed.c | 2 +- + gcc/fold-const.c | 2 +- + gcc/real.c | 10 +++++++++- + gcc/real.h | 4 ++-- + gcc/simplify-rtx.c | 16 ++++++++-------- + gcc/tree-call-cdce.c | 4 ++-- + gcc/tree-inline.c | 5 +++-- + gcc/tree-ssa-dom.c | 2 +- + gcc/tree-ssa-math-opts.c | 16 ++++++++-------- + gcc/tree-ssa-uncprop.c | 2 +- + gcc/tree-vect-patterns.c | 4 ++-- + gcc/tree.c | 6 +++--- + 26 files changed, 67 insertions(+), 72 deletions(-) + 2015-10-05 Richard Biener PR ipa/67783 diff --git a/gcc/builtins.c b/gcc/builtins.c index e20c1f8ff99..9a81a182de4 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8432,22 +8432,22 @@ fold_builtin_pow (location_t loc, tree fndecl, tree arg0, tree arg1, tree type) c = TREE_REAL_CST (arg1); /* Optimize pow(x,0.0) = 1.0. */ - if (REAL_VALUES_EQUAL (c, dconst0)) + if (real_equal (&c, &dconst0)) return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg0); /* Optimize pow(x,1.0) = x. */ - if (REAL_VALUES_EQUAL (c, dconst1)) + if (real_equal (&c, &dconst1)) return arg0; /* Optimize pow(x,-1.0) = 1.0/x. */ - if (REAL_VALUES_EQUAL (c, dconstm1)) + if (real_equal (&c, &dconstm1)) return fold_build2_loc (loc, RDIV_EXPR, type, build_real (type, dconst1), arg0); /* Optimize pow(x,0.5) = sqrt(x). */ if (flag_unsafe_math_optimizations - && REAL_VALUES_EQUAL (c, dconsthalf)) + && real_equal (&c, &dconsthalf)) { tree sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT); @@ -8461,7 +8461,7 @@ fold_builtin_pow (location_t loc, tree fndecl, tree arg0, tree arg1, tree type) const REAL_VALUE_TYPE dconstroot = real_value_truncate (TYPE_MODE (type), dconst_third ()); - if (REAL_VALUES_EQUAL (c, dconstroot)) + if (real_equal (&c, &dconstroot)) { tree cbrtfn = mathfn_built_in (type, BUILT_IN_CBRT); if (cbrtfn != NULL_TREE) @@ -8480,7 +8480,7 @@ fold_builtin_pow (location_t loc, tree fndecl, tree arg0, tree arg1, tree type) && !TREE_OVERFLOW (arg0) && (n > 0 || (!flag_trapping_math && !flag_errno_math) - || !REAL_VALUES_EQUAL (TREE_REAL_CST (arg0), dconst0))) + || !real_equal (&TREE_REAL_CST (arg0), &dconst0))) { REAL_VALUE_TYPE x; bool inexact; @@ -9373,7 +9373,7 @@ fold_builtin_load_exponent (location_t loc, tree arg0, tree arg1, /* Only proceed if the target mode can hold the resulting value. */ - if (REAL_VALUES_EQUAL (initial_result, trunc_result)) + if (real_equal (&initial_result, &trunc_result)) return build_real (type, trunc_result); } } diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c75d4895097..5af62aa5a34 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2015-10-05 Richard Sandiford + + * c-lex.c (interpret_float): Use real_equal instead of + REAL_VALUES_EQUAL. + 2015-10-04 Jason Merrill Implement N4514, C++ Extensions for Transactional Memory. diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 55ceb20a01f..c69f4a6e817 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -914,9 +914,9 @@ interpret_float (const cpp_token *token, unsigned int flags, } } /* We also give a warning if the value underflows. */ - else if (REAL_VALUES_EQUAL (real, dconst0) + else if (real_equal (&real, &dconst0) || (const_type != type - && REAL_VALUES_EQUAL (real_trunc, dconst0))) + && real_equal (&real_trunc, &dconst0))) { REAL_VALUE_TYPE realvoidmode; int oflow = real_from_string (&realvoidmode, copy); @@ -924,7 +924,7 @@ interpret_float (const cpp_token *token, unsigned int flags, : (oflow < 0 ? OT_UNDERFLOW : OT_OVERFLOW)); if (!(flags & CPP_N_USERDEF)) { - if (oflow < 0 || !REAL_VALUES_EQUAL (realvoidmode, dconst0)) + if (oflow < 0 || !real_equal (&realvoidmode, &dconst0)) warning (OPT_Woverflow, "floating constant truncated to zero"); } } diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index e0f169dc1d5..dfa2787c548 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2015-10-05 Richard Sandiford + + * c-typeck.c (c_tree_equal): Use real_equal instead of + REAL_VALUES_EQUAL. + 2015-10-04 Jason Merrill * c-parser.c (c_lex_one_token): Handle @synchronized. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index ad02d6cfda1..10cad367bb2 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12758,7 +12758,7 @@ c_tree_equal (tree t1, tree t2) return wi::eq_p (t1, t2); case REAL_CST: - return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2)); + return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2)); case STRING_CST: return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index d4c5665cf4d..a1057c962b5 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -3771,7 +3771,7 @@ aarch64_float_const_zero_rtx_p (rtx x) REAL_VALUE_FROM_CONST_DOUBLE (r, x); if (REAL_VALUE_MINUS_ZERO (r)) return !HONOR_SIGNED_ZEROS (GET_MODE (x)); - return REAL_VALUES_EQUAL (r, dconst0); + return real_equal (&r, &dconst0); } /* Return the fixed registers used for condition codes. */ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 02f5dc37ead..184ce509558 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -12107,7 +12107,7 @@ arm_const_double_rtx (rtx x) if (REAL_VALUE_MINUS_ZERO (r)) return 0; - if (REAL_VALUES_EQUAL (r, value_fp0)) + if (real_equal (&r, &value_fp0)) return 1; return 0; @@ -12319,7 +12319,7 @@ neon_valid_immediate (rtx op, machine_mode mode, int inverse, REAL_VALUE_FROM_CONST_DOUBLE (re, elt); - if (!REAL_VALUES_EQUAL (r0, re)) + if (!real_equal (&r0, &re)) return -1; } @@ -17594,7 +17594,7 @@ fp_const_from_val (REAL_VALUE_TYPE *r) if (!fp_consts_inited) init_fp_table (); - gcc_assert (REAL_VALUES_EQUAL (*r, value_fp0)); + gcc_assert (real_equal (r, &value_fp0)); return "0"; } diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c index 3308b55d9cf..0cac6ce2cf1 100644 --- a/gcc/config/fr30/fr30.c +++ b/gcc/config/fr30/fr30.c @@ -895,7 +895,7 @@ fr30_const_double_is_zero (rtx operand) REAL_VALUE_FROM_CONST_DOUBLE (d, operand); - return REAL_VALUES_EQUAL (d, dconst0); + return real_equal (&d, &dconst0); } /*}}}*/ diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index c26f37bb2ee..b7d96a55e44 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -4336,7 +4336,7 @@ standard_68881_constant_p (rtx x) REAL_VALUE_FROM_CONST_DOUBLE (r, x); - /* Use REAL_VALUES_IDENTICAL instead of REAL_VALUES_EQUAL so that -0.0 + /* Use REAL_VALUES_IDENTICAL instead of real_equal so that -0.0 is rejected. */ for (i = 0; i < 6; i++) { @@ -4347,7 +4347,7 @@ standard_68881_constant_p (rtx x) if (GET_MODE (x) == SFmode) return 0; - if (REAL_VALUES_EQUAL (r, values_68881[6])) + if (real_equal (&r, &values_68881[6])) return (codes_68881[6]); /* larger powers of ten in the constants ram are not used @@ -4371,7 +4371,7 @@ floating_exact_log2 (rtx x) exp = real_exponent (&r); real_2expN (&r1, exp, DFmode); - if (REAL_VALUES_EQUAL (r1, r)) + if (real_equal (&r1, &r)) return exp; return 0; diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 904201b22b0..a0d2e16fcff 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -10006,7 +10006,7 @@ fp_zero_operand (rtx op) return false; REAL_VALUE_FROM_CONST_DOUBLE (r, op); - return REAL_VALUES_EQUAL (r, dconst0) && ! REAL_VALUE_MINUS_ZERO (r); + return real_equal (&r, &dconst0) && ! REAL_VALUE_MINUS_ZERO (r); } /* Returns true if OP is a floating point value with value 1.0. */ @@ -10019,7 +10019,7 @@ fp_one_operand (rtx op) return false; REAL_VALUE_FROM_CONST_DOUBLE (r, op); - return REAL_VALUES_EQUAL (r, dconst1); + return real_equal (&r, &dconst1); } /* Return the TLS type for TLS symbols. */ diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 7e0a2c27629..2ad0e0adce8 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -661,11 +661,11 @@ vax_float_literal (rtx c) bool ok; real_from_integer (&s, mode, x, SIGNED); - if (REAL_VALUES_EQUAL (r, s)) + if (real_equal (&r, &s)) return true; ok = exact_real_inverse (mode, &s); gcc_assert (ok); - if (REAL_VALUES_EQUAL (r, s)) + if (real_equal (&r, &s)) return true; } return false; diff --git a/gcc/config/xtensa/predicates.md b/gcc/config/xtensa/predicates.md index d7dfa1107f8..e297b82de20 100644 --- a/gcc/config/xtensa/predicates.md +++ b/gcc/config/xtensa/predicates.md @@ -152,7 +152,7 @@ { REAL_VALUE_TYPE d; REAL_VALUE_FROM_CONST_DOUBLE (d, op); - return REAL_VALUES_EQUAL (d, dconst1); + return real_equal (&d, &dconst1); }) (define_predicate "fpmem_offset_operand" diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bc169b82bd0..d4fd5146eed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-10-05 Richard Sandiford + + * tree.c (cp_tree_equal): Use real_equal instead of + REAL_VALUES_EQUAL. + 2015-10-04 Jason Merrill Implement N4514, C++ Extensions for Transactional Memory. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 987ebe8e2aa..b9b801f311c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2852,7 +2852,7 @@ cp_tree_equal (tree t1, tree t2) return tree_int_cst_equal (t1, t2); case REAL_CST: - return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2)); + return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2)); case STRING_CST: return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2) diff --git a/gcc/cprop.c b/gcc/cprop.c index 28e9e54e93b..aa23a07513f 100644 --- a/gcc/cprop.c +++ b/gcc/cprop.c @@ -1355,7 +1355,7 @@ implicit_set_cond_p (const_rtx cond) { REAL_VALUE_TYPE d; REAL_VALUE_FROM_CONST_DOUBLE (d, cst); - if (REAL_VALUES_EQUAL (d, dconst0)) + if (real_equal (&d, &dconst0)) return 0; } else diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 610d6c1c7b5..fdd49d9b427 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -9708,13 +9708,6 @@ array of @code{HOST_WIDE_INT}, but all code should treat it as an opaque quantity. @end defmac -@deftypefn Macro int REAL_VALUES_EQUAL (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y}) -Compares for equality the two values, @var{x} and @var{y}. If the target -floating point format supports negative zeroes and/or NaNs, -@samp{REAL_VALUES_EQUAL (-0.0, 0.0)} is true, and -@samp{REAL_VALUES_EQUAL (NaN, NaN)} is false. -@end deftypefn - @deftypefn Macro int REAL_VALUES_LESS (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y}) Tests whether @var{x} is less than @var{y}. @end deftypefn diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 2ee0294c25d..ab75ad974d5 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7131,13 +7131,6 @@ array of @code{HOST_WIDE_INT}, but all code should treat it as an opaque quantity. @end defmac -@deftypefn Macro int REAL_VALUES_EQUAL (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y}) -Compares for equality the two values, @var{x} and @var{y}. If the target -floating point format supports negative zeroes and/or NaNs, -@samp{REAL_VALUES_EQUAL (-0.0, 0.0)} is true, and -@samp{REAL_VALUES_EQUAL (NaN, NaN)} is false. -@end deftypefn - @deftypefn Macro int REAL_VALUES_LESS (REAL_VALUE_TYPE @var{x}, REAL_VALUE_TYPE @var{y}) Tests whether @var{x} is less than @var{y}. @end deftypefn diff --git a/gcc/expmed.c b/gcc/expmed.c index 604a957a07b..07578e7c756 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -3239,7 +3239,7 @@ expand_mult (machine_mode mode, rtx op0, rtx op1, rtx target, REAL_VALUE_TYPE d; REAL_VALUE_FROM_CONST_DOUBLE (d, scalar_op1); - if (REAL_VALUES_EQUAL (d, dconst2)) + if (real_equal (&d, &dconst2)) { op0 = force_reg (GET_MODE (op0), op0); return expand_binop (mode, add_optab, op0, op0, diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 7231fd65d50..768b39b0469 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1176,7 +1176,7 @@ const_binop (enum tree_code code, tree arg1, tree arg2) /* Don't perform operation if it would raise a division by zero exception. */ if (code == RDIV_EXPR - && REAL_VALUES_EQUAL (d2, dconst0) + && real_equal (&d2, &dconst0) && (flag_trapping_math || ! MODE_HAS_INFINITIES (mode))) return NULL_TREE; diff --git a/gcc/real.c b/gcc/real.c index c1ff78d903f..d47f32ad78b 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -1078,6 +1078,14 @@ real_value_abs (const REAL_VALUE_TYPE *op0) return r; } +/* Return whether OP0 == OP1. */ + +bool +real_equal (const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1) +{ + return do_compare (op0, op1, -1) == 0; +} + bool real_compare (int icode, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1) @@ -1095,7 +1103,7 @@ real_compare (int icode, const REAL_VALUE_TYPE *op0, case GE_EXPR: return do_compare (op0, op1, -1) >= 0; case EQ_EXPR: - return do_compare (op0, op1, -1) == 0; + return real_equal (op0, op1); case NE_EXPR: return do_compare (op0, op1, -1) != 0; case UNORDERED_EXPR: diff --git a/gcc/real.h b/gcc/real.h index bd2a864b59b..0f20660eb91 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -247,8 +247,9 @@ extern bool real_isneg (const REAL_VALUE_TYPE *); /* Determine whether a floating-point value X is minus zero. */ extern bool real_isnegzero (const REAL_VALUE_TYPE *); -/* Compare two floating-point objects for bitwise identity. */ +/* Test relationships between reals. */ extern bool real_identical (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *); +extern bool real_equal (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *); /* Extend or truncate to a new mode. */ extern void real_convert (REAL_VALUE_TYPE *, machine_mode, @@ -333,7 +334,6 @@ extern const struct real_format arm_half_format; real_arithmetic (&(value), code, &(d1), &(d2)) #define REAL_VALUES_IDENTICAL(x, y) real_identical (&(x), &(y)) -#define REAL_VALUES_EQUAL(x, y) real_compare (EQ_EXPR, &(x), &(y)) #define REAL_VALUES_LESS(x, y) real_compare (LT_EXPR, &(x), &(y)) /* Determine whether a floating-point value X is infinite. */ diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 8d86e57bf79..b4d95a22a61 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2472,11 +2472,11 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, REAL_VALUE_TYPE d; REAL_VALUE_FROM_CONST_DOUBLE (d, trueop1); - if (REAL_VALUES_EQUAL (d, dconst2)) + if (real_equal (&d, &dconst2)) return simplify_gen_binary (PLUS, mode, op0, copy_rtx (op0)); if (!HONOR_SNANS (mode) - && REAL_VALUES_EQUAL (d, dconstm1)) + && real_equal (&d, &dconstm1)) return simplify_gen_unary (NEG, mode, op0, mode); } @@ -3102,14 +3102,14 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, REAL_VALUE_FROM_CONST_DOUBLE (d, trueop1); /* x/-1.0 is -x. */ - if (REAL_VALUES_EQUAL (d, dconstm1) + if (real_equal (&d, &dconstm1) && !HONOR_SNANS (mode)) return simplify_gen_unary (NEG, mode, op0, mode); /* Change FP division by a constant into multiplication. Only do this with -freciprocal-math. */ if (flag_reciprocal_math - && !REAL_VALUES_EQUAL (d, dconst0)) + && !real_equal (&d, &dconst0)) { REAL_ARITHMETIC (d, RDIV_EXPR, dconst1, d); tem = CONST_DOUBLE_FROM_REAL_VALUE (d, mode); @@ -3872,7 +3872,7 @@ simplify_const_binary_operation (enum rtx_code code, machine_mode mode, return 0; if (code == DIV - && REAL_VALUES_EQUAL (f1, dconst0) + && real_equal (&f1, &dconst0) && (flag_trapping_math || ! MODE_HAS_INFINITIES (mode))) return 0; @@ -3905,9 +3905,9 @@ simplify_const_binary_operation (enum rtx_code code, machine_mode mode, if (code == MULT && MODE_HAS_INFINITIES (mode) && HONOR_NANS (mode) && flag_trapping_math - && ((REAL_VALUE_ISINF (f0) && REAL_VALUES_EQUAL (f1, dconst0)) + && ((REAL_VALUE_ISINF (f0) && real_equal (&f1, &dconst0)) || (REAL_VALUE_ISINF (f1) - && REAL_VALUES_EQUAL (f0, dconst0)))) + && real_equal (&f0, &dconst0)))) /* Inf * 0 = NaN plus exception. */ return 0; @@ -4942,7 +4942,7 @@ simplify_const_relational_operation (enum rtx_code code, } return comparison_result (code, - (REAL_VALUES_EQUAL (d0, d1) ? CMP_EQ : + (real_equal (&d0, &d1) ? CMP_EQ : REAL_VALUES_LESS (d0, d1) ? CMP_LT : CMP_GT)); } diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c index e872eda0189..7a0275ad1c6 100644 --- a/gcc/tree-call-cdce.c +++ b/gcc/tree-call-cdce.c @@ -199,7 +199,7 @@ check_pow (gcall *pow_call) /* Only handle a fixed range of constant. */ REAL_VALUE_TYPE mv; REAL_VALUE_TYPE bcv = TREE_REAL_CST (base); - if (REAL_VALUES_EQUAL (bcv, dconst1)) + if (real_equal (&bcv, &dconst1)) return false; if (REAL_VALUES_LESS (bcv, dconst1)) return false; @@ -420,7 +420,7 @@ gen_conditions_for_pow_cst_base (tree base, tree expn, sure it is consistent with check_pow. */ REAL_VALUE_TYPE mv; REAL_VALUE_TYPE bcv = TREE_REAL_CST (base); - gcc_assert (!REAL_VALUES_EQUAL (bcv, dconst1) + gcc_assert (!real_equal (&bcv, &dconst1) && !REAL_VALUES_LESS (bcv, dconst1)); real_from_integer (&mv, TYPE_MODE (TREE_TYPE (base)), 256, UNSIGNED); gcc_assert (!REAL_VALUES_LESS (mv, bcv)); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ac9586ecdbf..9b525f388fc 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4092,8 +4092,9 @@ estimate_num_insns (gimple *stmt, eni_weights *weights) case BUILT_IN_POWF: case BUILT_IN_POWL: if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST - && REAL_VALUES_EQUAL - (TREE_REAL_CST (gimple_call_arg (stmt, 1)), dconst2)) + && (real_equal + (&TREE_REAL_CST (gimple_call_arg (stmt, 1)), + &dconst2))) return estimate_operator_cost (MULT_EXPR, weights, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 0)); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index d9408165157..c226da55340 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1158,7 +1158,7 @@ record_equality (tree x, tree y, class const_and_copies *const_and_copies) nonzero. */ if (HONOR_SIGNED_ZEROS (x) && (TREE_CODE (y) != REAL_CST - || REAL_VALUES_EQUAL (dconst0, TREE_REAL_CST (y)))) + || real_equal (&dconst0, &TREE_REAL_CST (y)))) return; const_and_copies->record_const_or_copy (x, y, prev_x); diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 97477391e0f..63245fcbb0f 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1145,7 +1145,7 @@ representable_as_half_series_p (REAL_VALUE_TYPE c, unsigned n, /* We have hit zero. The number is representable as a sum of powers of 0.5. */ - if (REAL_VALUES_EQUAL (res, dconst0)) + if (real_equal (&res, &dconst0)) { info->factors[i] = true; info->deepest = i + 1; @@ -1509,7 +1509,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc, unless signed zeros must be maintained. pow(-0,0.5) = +0, while sqrt(-0) = -0. */ if (sqrtfn - && REAL_VALUES_EQUAL (c, dconsthalf) + && real_equal (&c, &dconsthalf) && !HONOR_SIGNED_ZEROS (mode)) return build_and_insert_call (gsi, loc, sqrtfn, arg0); @@ -1527,7 +1527,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc, if (flag_unsafe_math_optimizations && cbrtfn && (gimple_val_nonnegative_real_p (arg0) || !HONOR_NANS (mode)) - && REAL_VALUES_EQUAL (c, dconst1_3)) + && real_equal (&c, &dconst1_3)) return build_and_insert_call (gsi, loc, cbrtfn, arg0); /* Optimize pow(x,1./6.) = cbrt(sqrt(x)). Don't do this optimization @@ -1541,7 +1541,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc, && (gimple_val_nonnegative_real_p (arg0) || !HONOR_NANS (mode)) && speed_p && hw_sqrt_exists - && REAL_VALUES_EQUAL (c, dconst1_6)) + && real_equal (&c, &dconst1_6)) { /* sqrt(x) */ sqrt_arg0 = build_and_insert_call (gsi, loc, sqrtfn, arg0); @@ -1556,7 +1556,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *gsi, location_t loc, if (flag_unsafe_math_optimizations && sqrtfn && hw_sqrt_exists - && (speed_p || REAL_VALUES_EQUAL (c, dconst1_4)) + && (speed_p || real_equal (&c, &dconst1_4)) && !HONOR_SIGNED_ZEROS (mode)) { unsigned int max_depth = speed_p @@ -3589,9 +3589,9 @@ pass_optimize_widening_mul::execute (function *fun) case BUILT_IN_POW: case BUILT_IN_POWL: if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST - && REAL_VALUES_EQUAL - (TREE_REAL_CST (gimple_call_arg (stmt, 1)), - dconst2) + && real_equal + (&TREE_REAL_CST (gimple_call_arg (stmt, 1)), + &dconst2) && convert_mult_to_fma (stmt, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 0))) diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c index d045341ebc3..0f16c508c94 100644 --- a/gcc/tree-ssa-uncprop.c +++ b/gcc/tree-ssa-uncprop.c @@ -153,7 +153,7 @@ associate_equivalences_with_edges (void) this value unless we know that the value is nonzero. */ if (HONOR_SIGNED_ZEROS (op0) && (TREE_CODE (op1) != REAL_CST - || REAL_VALUES_EQUAL (dconst0, TREE_REAL_CST (op1)))) + || real_equal (&dconst0, &TREE_REAL_CST (op1)))) continue; equivalency = XNEW (struct edge_equivalency); diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 830801a0224..48b5298645b 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -1084,7 +1084,7 @@ vect_recog_pow_pattern (vec *stmts, tree *type_in, if ((tree_fits_shwi_p (exp) && tree_to_shwi (exp) == 2) || (TREE_CODE (exp) == REAL_CST - && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconst2))) + && real_equal (&TREE_REAL_CST (exp), &dconst2))) { *type_in = TREE_TYPE (base); @@ -1095,7 +1095,7 @@ vect_recog_pow_pattern (vec *stmts, tree *type_in, /* Catch square root. */ if (TREE_CODE (exp) == REAL_CST - && REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconsthalf)) + && real_equal (&TREE_REAL_CST (exp), &dconsthalf)) { tree newfn = mathfn_built_in (TREE_TYPE (base), BUILT_IN_SQRT); *type_in = get_vectype_for_scalar_type (TREE_TYPE (base)); diff --git a/gcc/tree.c b/gcc/tree.c index af318495f0f..4bd3cae9ebf 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2546,7 +2546,7 @@ real_zerop (const_tree expr) switch (TREE_CODE (expr)) { case REAL_CST: - return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0) + return real_equal (&TREE_REAL_CST (expr), &dconst0) && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)))); case COMPLEX_CST: return real_zerop (TREE_REALPART (expr)) @@ -2576,7 +2576,7 @@ real_onep (const_tree expr) switch (TREE_CODE (expr)) { case REAL_CST: - return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst1) + return real_equal (&TREE_REAL_CST (expr), &dconst1) && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)))); case COMPLEX_CST: return real_onep (TREE_REALPART (expr)) @@ -2605,7 +2605,7 @@ real_minus_onep (const_tree expr) switch (TREE_CODE (expr)) { case REAL_CST: - return REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconstm1) + return real_equal (&TREE_REAL_CST (expr), &dconstm1) && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr)))); case COMPLEX_CST: return real_minus_onep (TREE_REALPART (expr)) -- 2.30.2