+2014-12-12 Marc Glisse <marc.glisse@inria.fr>
+
+ * real.h (HONOR_SNANS, HONOR_INFINITIES, HONOR_SIGNED_ZEROS,
+ HONOR_SIGN_DEPENDENT_ROUNDING): Replace macros with 3 overloaded
+ declarations.
+ * real.c (HONOR_NANS): Fix indentation.
+ (HONOR_SNANS, HONOR_INFINITIES, HONOR_SIGNED_ZEROS,
+ HONOR_SIGN_DEPENDENT_ROUNDING): Define three overloads.
+ * builtins.c (fold_builtin_cproj, fold_builtin_signbit,
+ fold_builtin_fmin_fmax, fold_builtin_classify): Simplify argument
+ of HONOR_*.
+ * fold-const.c (operand_equal_p, fold_comparison, fold_binary_loc):
+ Likewise.
+ * gimple-fold.c (gimple_val_nonnegative_real_p): Likewise.
+ * ifcvt.c (noce_try_move, noce_try_minmax, noce_try_abs): Likewise.
+ * omp-low.c (omp_reduction_init): Likewise.
+ * rtlanal.c (may_trap_p_1): Likewise.
+ * simplify-rtx.c (simplify_const_relational_operation): Likewise.
+ * tree-ssa-dom.c (record_equality, record_edge_info): Likewise.
+ * tree-ssa-phiopt.c (value_replacement, abs_replacement): Likewise.
+ * tree-ssa-reassoc.c (eliminate_using_constants): Likewise.
+ * tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
+
2014-12-12 Jan Hubicka <hubicka@ucw.cz>
* ipa-inline.c (ipa_inline): Fix condition on when
return NULL_TREE;
/* If there are no infinities, return arg. */
- if (! HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (type))))
+ if (! HONOR_INFINITIES (type))
return non_lvalue_loc (loc, arg);
/* Calculate the result when the argument is a constant. */
return omit_one_operand_loc (loc, type, integer_zero_node, arg);
/* If ARG's format doesn't have signed zeros, return "arg < 0.0". */
- if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_SIGNED_ZEROS (arg))
return fold_convert (type,
fold_build2_loc (loc, LT_EXPR, boolean_type_node, arg,
build_real (TREE_TYPE (arg), dconst0)));
omit_one_operand() ensures we create a non-lvalue. */
if (TREE_CODE (arg0) == REAL_CST
&& real_isnan (&TREE_REAL_CST (arg0))
- && (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0)))
+ && (! HONOR_SNANS (arg0)
|| ! TREE_REAL_CST (arg0).signalling))
return omit_one_operand_loc (loc, type, arg1, arg0);
if (TREE_CODE (arg1) == REAL_CST
&& real_isnan (&TREE_REAL_CST (arg1))
- && (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1)))
+ && (! HONOR_SNANS (arg1)
|| ! TREE_REAL_CST (arg1).signalling))
return omit_one_operand_loc (loc, type, arg0, arg1);
switch (builtin_index)
{
case BUILT_IN_ISINF:
- if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_INFINITIES (arg))
return omit_one_operand_loc (loc, type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
case BUILT_IN_ISFINITE:
if (!HONOR_NANS (arg)
- && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ && !HONOR_INFINITIES (arg))
return omit_one_operand_loc (loc, type, integer_one_node, arg);
if (TREE_CODE (arg) == REAL_CST)
return 1;
- if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0))))
+ if (!HONOR_SIGNED_ZEROS (arg0))
{
/* If we do not distinguish between signed and unsigned zero,
consider them equal. */
/* x != NaN is always true, other ops are always false. */
if (REAL_VALUE_ISNAN (cst)
- && ! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1))))
+ && ! HONOR_SNANS (arg1))
{
tem = (code == NE_EXPR) ? integer_one_node : integer_zero_node;
return omit_one_operand_loc (loc, type, tem, arg0);
if ((TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR)
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
&& ((TREE_CODE (TREE_OPERAND (arg0, 1)) == REAL_CST
- && !HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))))
+ && !HONOR_SNANS (arg0))
|| (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
&& TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))))
{
CASE_FLT_FN (BUILT_IN_SQRT):
/* sqrt(-0.0) is -0.0, and sqrt is not defined over other
nonnegative inputs. */
- if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (val))))
+ if (!HONOR_SIGNED_ZEROS (val))
return true;
break;
/* This optimization isn't valid if either A or B could be a NaN
or a signed zero. */
if (HONOR_NANS (if_info->x)
- || HONOR_SIGNED_ZEROS (GET_MODE (if_info->x)))
+ || HONOR_SIGNED_ZEROS (if_info->x))
return FALSE;
/* Check whether the operands of the comparison are A and in
/* ??? Reject modes with NaNs or signed zeros since we don't know how
they will be resolved with an SMIN/SMAX. It wouldn't be too hard
to get the target to tell us... */
- if (HONOR_SIGNED_ZEROS (GET_MODE (if_info->x))
+ if (HONOR_SIGNED_ZEROS (if_info->x)
|| HONOR_NANS (if_info->x))
return FALSE;
bool one_cmpl = false;
/* Reject modes with signed zeros. */
- if (HONOR_SIGNED_ZEROS (GET_MODE (if_info->x)))
+ if (HONOR_SIGNED_ZEROS (if_info->x))
return FALSE;
/* Recognize A and B as constituting an ABS or NABS. The canonical
if (SCALAR_FLOAT_TYPE_P (type))
{
REAL_VALUE_TYPE max, min;
- if (HONOR_INFINITIES (TYPE_MODE (type)))
+ if (HONOR_INFINITIES (type))
{
real_inf (&max);
real_arithmetic (&min, NEGATE_EXPR, &max, NULL);
if (SCALAR_FLOAT_TYPE_P (type))
{
REAL_VALUE_TYPE max;
- if (HONOR_INFINITIES (TYPE_MODE (type)))
+ if (HONOR_INFINITIES (type))
real_inf (&max);
else
real_maxval (&max, 0, TYPE_MODE (type));
bool
HONOR_NANS (const_rtx x)
{
- return HONOR_NANS (GET_MODE (x));
+ return HONOR_NANS (GET_MODE (x));
}
+/* Like HONOR_NANs, but true if we honor signaling NaNs (or sNaNs). */
+
+bool
+HONOR_SNANS (machine_mode m)
+{
+ return flag_signaling_nans && HONOR_NANS (m);
+}
+
+bool
+HONOR_SNANS (const_tree t)
+{
+ return HONOR_SNANS (element_mode (t));
+}
+
+bool
+HONOR_SNANS (const_rtx x)
+{
+ return HONOR_SNANS (GET_MODE (x));
+}
+
+/* As for HONOR_NANS, but true if the mode can represent infinity and
+ the treatment of infinite values is important. */
+
+bool
+HONOR_INFINITIES (machine_mode m)
+{
+ return MODE_HAS_INFINITIES (m) && !flag_finite_math_only;
+}
+
+bool
+HONOR_INFINITIES (const_tree t)
+{
+ return HONOR_INFINITIES (element_mode (t));
+}
+
+bool
+HONOR_INFINITIES (const_rtx x)
+{
+ return HONOR_INFINITIES (GET_MODE (x));
+}
+
+/* Like HONOR_NANS, but true if the given mode distinguishes between
+ positive and negative zero, and the sign of zero is important. */
+
+bool
+HONOR_SIGNED_ZEROS (machine_mode m)
+{
+ return MODE_HAS_SIGNED_ZEROS (m) && flag_signed_zeros;
+}
+
+bool
+HONOR_SIGNED_ZEROS (const_tree t)
+{
+ return HONOR_SIGNED_ZEROS (element_mode (t));
+}
+
+bool
+HONOR_SIGNED_ZEROS (const_rtx x)
+{
+ return HONOR_SIGNED_ZEROS (GET_MODE (x));
+}
+
+/* Like HONOR_NANS, but true if given mode supports sign-dependent rounding,
+ and the rounding mode is important. */
+
+bool
+HONOR_SIGN_DEPENDENT_ROUNDING (machine_mode m)
+{
+ return MODE_HAS_SIGN_DEPENDENT_ROUNDING (m) && flag_rounding_math;
+}
+
+bool
+HONOR_SIGN_DEPENDENT_ROUNDING (const_tree t)
+{
+ return HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (t));
+}
+
+bool
+HONOR_SIGN_DEPENDENT_ROUNDING (const_rtx x)
+{
+ return HONOR_SIGN_DEPENDENT_ROUNDING (GET_MODE (x));
+}
(FLOAT_MODE_P (MODE) \
&& FLOAT_MODE_FORMAT (MODE)->has_sign_dependent_rounding)
+/* Declare functions in real.c. */
+
/* True if the given mode has a NaN representation and the treatment of
NaN operands is important. Certain optimizations, such as folding
x * 0 into 0, are not correct for NaN operands, and are normally
extern bool HONOR_NANS (const_rtx);
/* Like HONOR_NANs, but true if we honor signaling NaNs (or sNaNs). */
-#define HONOR_SNANS(MODE) (flag_signaling_nans && HONOR_NANS (MODE))
+extern bool HONOR_SNANS (machine_mode);
+extern bool HONOR_SNANS (const_tree);
+extern bool HONOR_SNANS (const_rtx);
/* As for HONOR_NANS, but true if the mode can represent infinity and
the treatment of infinite values is important. */
-#define HONOR_INFINITIES(MODE) \
- (MODE_HAS_INFINITIES (MODE) && !flag_finite_math_only)
+extern bool HONOR_INFINITIES (machine_mode);
+extern bool HONOR_INFINITIES (const_tree);
+extern bool HONOR_INFINITIES (const_rtx);
/* Like HONOR_NANS, but true if the given mode distinguishes between
positive and negative zero, and the sign of zero is important. */
-#define HONOR_SIGNED_ZEROS(MODE) \
- (MODE_HAS_SIGNED_ZEROS (MODE) && flag_signed_zeros)
+extern bool HONOR_SIGNED_ZEROS (machine_mode);
+extern bool HONOR_SIGNED_ZEROS (const_tree);
+extern bool HONOR_SIGNED_ZEROS (const_rtx);
/* Like HONOR_NANS, but true if given mode supports sign-dependent rounding,
and the rounding mode is important. */
-#define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \
- (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && flag_rounding_math)
-
-/* Declare functions in real.c. */
+extern bool HONOR_SIGN_DEPENDENT_ROUNDING (machine_mode);
+extern bool HONOR_SIGN_DEPENDENT_ROUNDING (const_tree);
+extern bool HONOR_SIGN_DEPENDENT_ROUNDING (const_rtx);
/* Binary or unary arithmetic on tree_code. */
extern bool real_arithmetic (REAL_VALUE_TYPE *, int, const REAL_VALUE_TYPE *,
case MOD:
case UDIV:
case UMOD:
- if (HONOR_SNANS (GET_MODE (x)))
+ if (HONOR_SNANS (x))
return 1;
if (SCALAR_FLOAT_MODE_P (GET_MODE (x)))
return flag_trapping_math;
case EQ:
case NE:
- if (HONOR_SNANS (GET_MODE (x)))
+ if (HONOR_SNANS (x))
return 1;
/* Often comparison is CC mode, so check operand modes. */
- if (HONOR_SNANS (GET_MODE (XEXP (x, 0)))
- || HONOR_SNANS (GET_MODE (XEXP (x, 1))))
+ if (HONOR_SNANS (XEXP (x, 0))
+ || HONOR_SNANS (XEXP (x, 1)))
return 1;
break;
if ((! HONOR_NANS (trueop0)
|| code == UNEQ || code == UNLE || code == UNGE
|| ((code == LT || code == GT || code == LTGT)
- && ! HONOR_SNANS (GET_MODE (trueop0))))
+ && ! HONOR_SNANS (trueop0)))
&& rtx_equal_p (trueop0, trueop1)
&& ! side_effects_p (trueop0))
return comparison_result (code, CMP_EQ);
variable compared against zero. If we're honoring signed zeros,
then we cannot record this value unless we know that the value is
nonzero. */
- if (HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (x)))
+ if (HONOR_SIGNED_ZEROS (x)
&& (TREE_CODE (y) != REAL_CST
|| REAL_VALUES_EQUAL (dconst0, TREE_REAL_CST (y))))
return;
tree cond = build2 (code, boolean_type_node, op0, op1);
tree inverted = invert_truthvalue_loc (loc, cond);
bool can_infer_simple_equiv
- = !(HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op0)))
+ = !(HONOR_SIGNED_ZEROS (op0)
&& real_zerop (op0));
struct edge_info *edge_info;
tree cond = build2 (code, boolean_type_node, op0, op1);
tree inverted = invert_truthvalue_loc (loc, cond);
bool can_infer_simple_equiv
- = !(HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op1)))
+ = !(HONOR_SIGNED_ZEROS (op1)
&& (TREE_CODE (op1) == SSA_NAME || real_zerop (op1)));
struct edge_info *edge_info;
/* If the type says honor signed zeros we cannot do this
optimization. */
- if (HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg1))))
+ if (HONOR_SIGNED_ZEROS (arg1))
return 0;
/* If there is a statement in MIDDLE_BB that defines one of the PHI
/* If the type says honor signed zeros we cannot do this
optimization. */
- if (HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg1))))
+ if (HONOR_SIGNED_ZEROS (arg1))
return false;
/* OTHER_BLOCK must have only one executable statement which must have the
if (integer_zerop (oelast->op)
|| (FLOAT_TYPE_P (type)
&& !HONOR_NANS (type)
- && !HONOR_SIGNED_ZEROS (TYPE_MODE (type))
+ && !HONOR_SIGNED_ZEROS (type)
&& real_zerop (oelast->op)))
{
if (ops->length () != 1)
}
else if (integer_onep (oelast->op)
|| (FLOAT_TYPE_P (type)
- && !HONOR_SNANS (TYPE_MODE (type))
+ && !HONOR_SNANS (type)
&& real_onep (oelast->op)))
{
if (ops->length () != 1)
the sign of a variable compared against zero. If
we're honoring signed zeros, then we cannot record
this value unless we know that the value is nonzero. */
- if (HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op0)))
+ if (HONOR_SIGNED_ZEROS (op0)
&& (TREE_CODE (op1) != REAL_CST
|| REAL_VALUES_EQUAL (dconst0, TREE_REAL_CST (op1))))
continue;