diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 875ade3..26bdd66 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1937,9 +1937,8 @@ operand_equal_for_comparison_p (arg0, arg1, other) /* Make sure shorter operand is extended the right way to match the longer operand. */ - primarg1 = convert (signed_or_unsigned_type (unsignedp1, - TREE_TYPE (primarg1)), - primarg1); + primarg1 = convert ((*lang_hooks.types.signed_or_unsigned_type) + (unsignedp1, TREE_TYPE (primarg1)), primarg1); if (operand_equal_p (arg0, convert (type, primarg1), 0)) return 1; @@ -2622,7 +2621,7 @@ all_ones_mask_p (mask, size) tree tmask; tmask = build_int_2 (~0, ~0); - TREE_TYPE (tmask) = signed_type (type); + TREE_TYPE (tmask) = (*lang_hooks.types.signed_type) (type); force_fit_type (tmask, 0); return tree_int_cst_equal (mask, @@ -3063,7 +3062,7 @@ build_range_check (type, exp, in_p, low, high) else if (integer_zerop (low)) { - utype = unsigned_type (etype); + utype = (*lang_hooks.types.unsigned_type) (etype); return build_range_check (type, convert (utype, exp), 1, 0, convert (utype, high)); } @@ -3316,7 +3315,7 @@ unextend (c, p, unsignedp, mask) zero or one, and the conversion to a signed type can never overflow. We could get an overflow if this conversion is done anywhere else. */ if (TREE_UNSIGNED (type)) - temp = convert (signed_type (type), temp); + temp = convert ((*lang_hooks.types.signed_type) (type), temp); temp = const_binop (LSHIFT_EXPR, temp, size_int (modesize - 1), 0); temp = const_binop (RSHIFT_EXPR, temp, size_int (modesize - p - 1), 0); @@ -5939,7 +5938,7 @@ fold (expr) || TREE_CODE (arg0) == ROUND_MOD_EXPR) && integer_pow2p (TREE_OPERAND (arg0, 1))) { - tree newtype = unsigned_type (TREE_TYPE (arg0)); + tree newtype = (*lang_hooks.types.unsigned_type) (TREE_TYPE (arg0)); tree newmod = build (TREE_CODE (arg0), newtype, convert (newtype, TREE_OPERAND (arg0, 0)), convert (newtype, TREE_OPERAND (arg0, 1))); @@ -6114,25 +6113,18 @@ fold (expr) && TREE_UNSIGNED (TREE_TYPE (arg1)) /* signed_type does not work on pointer types. */ && INTEGRAL_TYPE_P (TREE_TYPE (arg1))) - switch (TREE_CODE (t)) - { - case LE_EXPR: - return fold (build (GE_EXPR, type, - convert (signed_type (TREE_TYPE (arg0)), - arg0), - convert (signed_type (TREE_TYPE (arg1)), - integer_zero_node))); - case GT_EXPR: - return fold (build (LT_EXPR, type, - convert (signed_type (TREE_TYPE (arg0)), - arg0), - convert (signed_type (TREE_TYPE (arg1)), - integer_zero_node))); - - default: - break; - } - + { + if (TREE_CODE (t) == LE_EXPR || TREE_CODE (t) == GT_EXPR) + { + tree st0, st1; + st0 = (*lang_hooks.types.signed_type) (TREE_TYPE (arg0)); + st1 = (*lang_hooks.types.signed_type) (TREE_TYPE (arg1)); + return fold + (build (TREE_CODE (t) == LE_EXPR ? GE_EXPR: LT_EXPR, + type, convert (st0, arg0), + convert (st1, integer_zero_node))); + } + } else if (TREE_INT_CST_HIGH (arg1) == 0 && (TREE_INT_CST_LOW (arg1) == ((unsigned HOST_WIDE_INT) 2 << (width - 1)) - 1) @@ -6506,14 +6498,16 @@ fold (expr) case GE_EXPR: case GT_EXPR: if (TREE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1); + arg1 = convert ((*lang_hooks.types.signed_type) + (TREE_TYPE (arg1)), arg1); return pedantic_non_lvalue (convert (type, fold (build1 (ABS_EXPR, TREE_TYPE (arg1), arg1)))); case LE_EXPR: case LT_EXPR: if (TREE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1); + arg1 = convert ((lang_hooks.types.signed_type) + (TREE_TYPE (arg1)), arg1); return pedantic_non_lvalue (negate_expr (convert (type, fold (build1 (ABS_EXPR, |