+2015-10-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * 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 <rguenther@suse.de>
PR ipa/67783
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);
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)
&& !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;
/* 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);
}
}
+2015-10-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * c-lex.c (interpret_float): Use real_equal instead of
+ REAL_VALUES_EQUAL.
+
2015-10-04 Jason Merrill <jason@redhat.com>
Implement N4514, C++ Extensions for Transactional Memory.
}
}
/* 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);
: (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");
}
}
+2015-10-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * c-typeck.c (c_tree_equal): Use real_equal instead of
+ REAL_VALUES_EQUAL.
+
2015-10-04 Jason Merrill <jason@redhat.com>
* c-parser.c (c_lex_one_token): Handle @synchronized.
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)
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. */
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;
REAL_VALUE_FROM_CONST_DOUBLE (re, elt);
- if (!REAL_VALUES_EQUAL (r0, re))
+ if (!real_equal (&r0, &re))
return -1;
}
if (!fp_consts_inited)
init_fp_table ();
- gcc_assert (REAL_VALUES_EQUAL (*r, value_fp0));
+ gcc_assert (real_equal (r, &value_fp0));
return "0";
}
REAL_VALUE_FROM_CONST_DOUBLE (d, operand);
- return REAL_VALUES_EQUAL (d, dconst0);
+ return real_equal (&d, &dconst0);
}
/*}}}*/
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++)
{
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
exp = real_exponent (&r);
real_2expN (&r1, exp, DFmode);
- if (REAL_VALUES_EQUAL (r1, r))
+ if (real_equal (&r1, &r))
return exp;
return 0;
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. */
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. */
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;
{
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"
+2015-10-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * tree.c (cp_tree_equal): Use real_equal instead of
+ REAL_VALUES_EQUAL.
+
2015-10-04 Jason Merrill <jason@redhat.com>
Implement N4514, C++ Extensions for Transactional Memory.
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)
{
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
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
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
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,
/* 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;
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)
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:
/* 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,
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. */
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);
}
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);
return 0;
if (code == DIV
- && REAL_VALUES_EQUAL (f1, dconst0)
+ && real_equal (&f1, &dconst0)
&& (flag_trapping_math || ! MODE_HAS_INFINITIES (mode)))
return 0;
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;
}
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));
}
/* 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;
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));
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));
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);
/* 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;
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);
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
&& (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);
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
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)))
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);
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);
/* 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));
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))
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))
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))