Hello,after HONOR_NANS, I am turning the other HONOR_* macros into functions. As a reminder, the goal is both to make uses shorter and to fix the answer for non-native vector types.
Bootstrap+testsuite on x86_64-linux-gnu. 2014-12-12 Marc Glisse <marc.gli...@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. -- Marc Glisse
Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 218639) +++ gcc/builtins.c (working copy) @@ -7671,21 +7671,21 @@ build_complex_cproj (tree type, bool neg return type. Return NULL_TREE if no simplification can be made. */ static tree fold_builtin_cproj (location_t loc, tree arg, tree type) { if (!validate_arg (arg, COMPLEX_TYPE) || TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) != REAL_TYPE) 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. */ if (TREE_CODE (arg) == COMPLEX_CST) { const REAL_VALUE_TYPE *real = TREE_REAL_CST_PTR (TREE_REALPART (arg)); const REAL_VALUE_TYPE *imag = TREE_REAL_CST_PTR (TREE_IMAGPART (arg)); if (real_isinf (real) || real_isinf (imag)) return build_complex_cproj (type, imag->sign); @@ -8942,21 +8942,21 @@ fold_builtin_signbit (location_t loc, tr return (REAL_VALUE_NEGATIVE (c) ? build_one_cst (type) : build_zero_cst (type)); } /* If ARG is non-negative, the result is always zero. */ if (tree_expr_nonnegative_p (arg)) 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))); return NULL_TREE; } /* Fold function call to builtin copysign, copysignf or copysignl with arguments ARG1 and ARG2. Return NULL_TREE if no simplification can be made. */ @@ -9136,26 +9136,26 @@ fold_builtin_fmin_fmax (location_t loc, tree res = do_mpfr_arg2 (arg0, arg1, type, (max ? mpfr_max : mpfr_min)); if (res) return res; /* If either argument is NaN, return the other one. Avoid the transformation if we get (and honor) a signalling NaN. Using 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); /* Transform fmin/fmax(x,x) -> x. */ if (operand_equal_p (arg0, arg1, OEP_PURE_SAME)) return omit_one_operand_loc (loc, type, arg0, arg1); /* Convert fmin/fmax to MIN_EXPR/MAX_EXPR. C99 requires these functions to return the numeric arg if the other one is NaN. These tree codes don't honor that, so only transform if @@ -9552,21 +9552,21 @@ fold_builtin_classify (location_t loc, t { tree type = TREE_TYPE (TREE_TYPE (fndecl)); REAL_VALUE_TYPE r; if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; 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) { r = TREE_REAL_CST (arg); if (real_isinf (&r)) return real_compare (GT_EXPR, &r, &dconst0) ? integer_one_node : integer_minus_one_node; else return integer_zero_node; @@ -9601,21 +9601,21 @@ fold_builtin_classify (location_t loc, t tmp = fold_build3_loc (loc, COND_EXPR, integer_type_node, isinf_call, tmp, integer_zero_node); } return tmp; } 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) { r = TREE_REAL_CST (arg); return real_isfinite (&r) ? integer_one_node : integer_zero_node; } return NULL_TREE; Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 218639) +++ gcc/fold-const.c (working copy) @@ -2793,21 +2793,21 @@ operand_equal_p (const_tree arg0, const_ case FIXED_CST: return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (arg0), TREE_FIXED_CST (arg1)); case REAL_CST: if (REAL_VALUES_IDENTICAL (TREE_REAL_CST (arg0), TREE_REAL_CST (arg1))) 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. */ if (real_zerop (arg0) && real_zerop (arg1)) return 1; } return 0; case VECTOR_CST: { @@ -9158,21 +9158,21 @@ fold_comparison (location_t loc, enum tr real_value_negate (&cst))); /* IEEE doesn't distinguish +0 and -0 in comparisons. */ /* a CMP (-0) -> a CMP 0 */ if (REAL_VALUE_MINUS_ZERO (cst)) return fold_build2_loc (loc, code, type, arg0, build_real (TREE_TYPE (arg1), dconst0)); /* 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); } /* Fold comparisons against infinity. */ if (REAL_VALUE_ISINF (cst) && MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg1)))) { tem = fold_inf_compare (loc, code, type, arg0, arg1); @@ -12801,21 +12801,21 @@ fold_binary_loc (location_t loc, case LE_EXPR: case GE_EXPR: tem = fold_comparison (loc, code, type, op0, op1); if (tem != NULL_TREE) return tem; /* Transform comparisons of the form X +- C CMP X. */ 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))))) { tree arg01 = TREE_OPERAND (arg0, 1); enum tree_code code0 = TREE_CODE (arg0); int is_positive; if (TREE_CODE (arg01) == REAL_CST) is_positive = REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg01)) ? -1 : 1; else Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c (revision 218639) +++ gcc/gimple-fold.c (working copy) @@ -5825,21 +5825,21 @@ gimple_val_nonnegative_real_p (tree val) CASE_FLT_FN (BUILT_IN_EXP2): CASE_FLT_FN (BUILT_IN_FABS): CASE_FLT_FN (BUILT_IN_FDIM): CASE_FLT_FN (BUILT_IN_HYPOT): CASE_FLT_FN (BUILT_IN_POW10): return true; 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; CASE_FLT_FN (BUILT_IN_POWI): /* True if the second argument is an even integer. */ arg1 = gimple_call_arg (def_stmt, 1); if (TREE_CODE (arg1) == INTEGER_CST && (TREE_INT_CST_LOW (arg1) & 1) == 0) Index: gcc/ifcvt.c =================================================================== --- gcc/ifcvt.c (revision 218639) +++ gcc/ifcvt.c (working copy) @@ -1056,21 +1056,21 @@ noce_try_move (struct noce_if_info *if_i enum rtx_code code = GET_CODE (cond); rtx y; rtx_insn *seq; if (code != NE && code != EQ) return FALSE; /* 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 either order. */ if ((rtx_equal_p (if_info->a, XEXP (cond, 0)) && rtx_equal_p (if_info->b, XEXP (cond, 1))) || (rtx_equal_p (if_info->a, XEXP (cond, 1)) && rtx_equal_p (if_info->b, XEXP (cond, 0)))) { if (!rtx_interchangeable_p (if_info->a, if_info->b)) @@ -1947,21 +1947,21 @@ static int noce_try_minmax (struct noce_if_info *if_info) { rtx cond, target; rtx_insn *earliest, *seq; enum rtx_code code, op; int unsignedp; /* ??? 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; cond = noce_get_alt_condition (if_info, if_info->a, &earliest); if (!cond) return FALSE; /* Verify the condition is of the form we expect, and canonicalize the comparison code. */ code = GET_CODE (cond); @@ -2041,21 +2041,21 @@ noce_try_minmax (struct noce_if_info *if static int noce_try_abs (struct noce_if_info *if_info) { rtx cond, target, a, b, c; rtx_insn *earliest, *seq; int negate; 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 form is a branch around the negation, taken when the object is the first operand of a comparison against 0 that evaluates to true. */ a = if_info->a; b = if_info->b; if (GET_CODE (a) == NEG && rtx_equal_p (XEXP (a, 0), b)) negate = 0; else if (GET_CODE (b) == NEG && rtx_equal_p (XEXP (b, 0), a)) Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c (revision 218639) +++ gcc/omp-low.c (working copy) @@ -3032,40 +3032,40 @@ omp_reduction_init (tree clause, tree ty case EQ_EXPR: return fold_convert_loc (loc, type, integer_one_node); case BIT_AND_EXPR: return fold_convert_loc (loc, type, integer_minus_one_node); case MAX_EXPR: 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); } else real_maxval (&min, 1, TYPE_MODE (type)); return build_real (type, min); } else { gcc_assert (INTEGRAL_TYPE_P (type)); return TYPE_MIN_VALUE (type); } case MIN_EXPR: 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)); return build_real (type, max); } else { gcc_assert (INTEGRAL_TYPE_P (type)); return TYPE_MAX_VALUE (type); } Index: gcc/real.c =================================================================== --- gcc/real.c (revision 218639) +++ gcc/real.c (working copy) @@ -4996,13 +4996,95 @@ HONOR_NANS (machine_mode m) bool HONOR_NANS (const_tree t) { return HONOR_NANS (element_mode (t)); } 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)); +} Index: gcc/real.h =================================================================== --- gcc/real.h (revision 218639) +++ gcc/real.h (working copy) @@ -188,48 +188,53 @@ extern const struct real_format * #define MODE_HAS_NANS(MODE) \ (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_nans) #define MODE_HAS_INFINITIES(MODE) \ (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_inf) #define MODE_HAS_SIGNED_ZEROS(MODE) \ (FLOAT_MODE_P (MODE) && FLOAT_MODE_FORMAT (MODE)->has_signed_zero) #define MODE_HAS_SIGN_DEPENDENT_ROUNDING(MODE) \ (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 disabled for modes with NaNs. The user can ask for them to be done anyway using the -funsafe-math-optimizations switch. */ extern bool HONOR_NANS (machine_mode); extern bool HONOR_NANS (const_tree); 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 *, const REAL_VALUE_TYPE *); /* Compare reals by tree_code. */ extern bool real_compare (int, const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *); /* Determine whether a floating-point value X is infinite. */ extern bool real_isinf (const REAL_VALUE_TYPE *); Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c (revision 218639) +++ gcc/rtlanal.c (working copy) @@ -2519,21 +2519,21 @@ may_trap_p_1 (const_rtx x, unsigned flag GET_MODE (x), code_changed); } return 0; /* Division by a non-constant might trap. */ case DIV: 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; if (!CONSTANT_P (XEXP (x, 1)) || (XEXP (x, 1) == const0_rtx)) return 1; break; case EXPR_LIST: /* An EXPR_LIST is used to represent a function call. This certainly may trap. */ @@ -2556,25 +2556,25 @@ may_trap_p_1 (const_rtx x, unsigned flag return 1; /* But often the compare has some CC mode, so check operand modes as well. */ if (HONOR_NANS (XEXP (x, 0)) || HONOR_NANS (XEXP (x, 1))) return 1; break; 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; case FIX: /* Conversion of floating point might trap. */ if (flag_trapping_math && HONOR_NANS (XEXP (x, 0))) return 1; break; case NEG: Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c (revision 218639) +++ gcc/simplify-rtx.c (working copy) @@ -4750,21 +4750,21 @@ simplify_const_relational_operation (enu if (! HONOR_NANS (mode) && code == UNORDERED) return const0_rtx; /* For modes without NaNs, if the two operands are equal, we know the result except if they have side-effects. Even with NaNs we know the result of unordered comparisons and, if signaling NaNs are irrelevant, also the result of LT/GT/LTGT. */ 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); /* If the operands are floating-point constants, see if we can fold the result. */ if (CONST_DOUBLE_AS_FLOAT_P (trueop0) && CONST_DOUBLE_AS_FLOAT_P (trueop1) && SCALAR_FLOAT_MODE_P (GET_MODE (trueop0))) { Index: gcc/tree-ssa-dom.c =================================================================== --- gcc/tree-ssa-dom.c (revision 218639) +++ gcc/tree-ssa-dom.c (working copy) @@ -1652,21 +1652,21 @@ record_equality (tree x, tree y) y = prev_y; /* After the swapping, we must have one SSA_NAME. */ if (TREE_CODE (x) != SSA_NAME) return; /* For IEEE, -0.0 == 0.0, so we don't necessarily know 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 (x))) + if (HONOR_SIGNED_ZEROS (x) && (TREE_CODE (y) != REAL_CST || REAL_VALUES_EQUAL (dconst0, TREE_REAL_CST (y)))) return; record_const_or_copy_1 (x, y, prev_x); } /* Returns true when STMT is a simple iv increment. It detects the following situation: @@ -1893,21 +1893,21 @@ record_edge_info (basic_block bb) : boolean_true_node); } } else if (is_gimple_min_invariant (op0) && (TREE_CODE (op1) == SSA_NAME || is_gimple_min_invariant (op1))) { 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; edge_info = allocate_edge_info (true_edge); record_conditions (edge_info, cond, inverted); if (can_infer_simple_equiv && code == EQ_EXPR) { edge_info->lhs = op1; edge_info->rhs = op0; @@ -1923,21 +1923,21 @@ record_edge_info (basic_block bb) } } else if (TREE_CODE (op0) == SSA_NAME && (TREE_CODE (op1) == SSA_NAME || is_gimple_min_invariant (op1))) { 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; edge_info = allocate_edge_info (true_edge); record_conditions (edge_info, cond, inverted); if (can_infer_simple_equiv && code == EQ_EXPR) { edge_info->lhs = op0; edge_info->rhs = op1; Index: gcc/tree-ssa-phiopt.c =================================================================== --- gcc/tree-ssa-phiopt.c (revision 218639) +++ gcc/tree-ssa-phiopt.c (working copy) @@ -742,21 +742,21 @@ value_replacement (basic_block cond_bb, tree arg0, tree arg1) { gimple_stmt_iterator gsi; gimple cond; edge true_edge, false_edge; enum tree_code code; bool emtpy_or_with_defined_p = true; /* 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 arguments, then adjust arg0 or arg1. */ gsi = gsi_start_nondebug_after_labels_bb (middle_bb); while (!gsi_end_p (gsi)) { gimple stmt = gsi_stmt (gsi); tree lhs; gsi_next_nondebug (&gsi); @@ -1175,21 +1175,21 @@ abs_replacement (basic_block cond_bb, ba gimple_stmt_iterator gsi; edge true_edge, false_edge; gimple assign; edge e; tree rhs, lhs; bool negate; enum tree_code cond_code; /* 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 form arg0 = -arg1 or arg1 = -arg0. */ assign = last_and_only_stmt (middle_bb); /* If we did not find the proper negation assignment, then we can not optimize. */ if (assign == NULL) return false; Index: gcc/tree-ssa-reassoc.c =================================================================== --- gcc/tree-ssa-reassoc.c (revision 218639) +++ gcc/tree-ssa-reassoc.c (working copy) @@ -960,37 +960,37 @@ eliminate_using_constants (enum tree_cod fprintf (dump_file, "Found | 0, removing\n"); ops->pop (); reassociate_stats.ops_eliminated++; } } break; case MULT_EXPR: 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) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Found * 0, removing all other ops\n"); reassociate_stats.ops_eliminated += ops->length () - 1; ops->truncate (1); ops->quick_push (oelast); return; } } 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) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Found * 1, removing\n"); ops->pop (); reassociate_stats.ops_eliminated++; return; } Index: gcc/tree-ssa-uncprop.c =================================================================== --- gcc/tree-ssa-uncprop.c (revision 218639) +++ gcc/tree-ssa-uncprop.c (working copy) @@ -153,21 +153,21 @@ associate_equivalences_with_edges (void) else if (TREE_CODE (op0) == SSA_NAME && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op0) && (is_gimple_min_invariant (op1) || (TREE_CODE (op1) == SSA_NAME && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op1)))) { /* For IEEE, -0.0 == 0.0, so we don't necessarily know 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; equivalency = XNEW (struct edge_equivalency); equivalency->lhs = op0; equivalency->rhs = op1; if (code == EQ_EXPR) true_edge->aux = equivalency; else