> I'm not sure about this bit. Couldn't [snip cse.c code] > simply be replaced by: > > /* We can't simplify extension ops unless we know the > original mode. */ > if ((code == ZERO_EXTEND || code == SIGN_EXTEND) > && mode_arg0 == VOIDmode) > break; > > new = simplify_unary_operation (code, mode, > const_arg0 ? const_arg0 : folded_arg0, > mode_arg0); > ? > > (Sorry if I'm repeating earlier discussion here.)
I think so -- I was just trying to resemble the existing code as much as possible (stage3), but it's probably better to clean up instead. What do you thing about the simplify-rtx.c part instead? Paolo
2008-09-06 Paolo Bonzini <[EMAIL PROTECTED]> * cse.c (fold_rtx): Let simplify_unary_operation handle CONSTs. * explow.c (plus_constant): Don't exit early if c == 0, to allow canonicalizing CONSTs. * simplify-rtx.c (simplify_plus_minus): Likewise. Index: cse.c =================================================================== --- cse.c (revision 134435) +++ cse.c (working copy) @@ -3138,33 +3138,20 @@ fold_rtx (rtx x, rtx insn) { case RTX_UNARY: { - int is_const = 0; - /* We can't simplify extension ops unless we know the original mode. */ if ((code == ZERO_EXTEND || code == SIGN_EXTEND) && mode_arg0 == VOIDmode) break; - /* If we had a CONST, strip it off and put it back later if we - fold. */ + /* If we had a CONST, strip it off and let simplify_unary_operation + put it back if it can simplify something. */ if (const_arg0 != 0 && GET_CODE (const_arg0) == CONST) - is_const = 1, const_arg0 = XEXP (const_arg0, 0); + const_arg0 = XEXP (const_arg0, 0); new = simplify_unary_operation (code, mode, const_arg0 ? const_arg0 : folded_arg0, mode_arg0); - /* NEG of PLUS could be converted into MINUS, but that causes - expressions of the form - (CONST (MINUS (CONST_INT) (SYMBOL_REF))) - which many ports mistakenly treat as LEGITIMATE_CONSTANT_P. - FIXME: those ports should be fixed. */ - if (new != 0 && is_const - && GET_CODE (new) == PLUS - && (GET_CODE (XEXP (new, 0)) == SYMBOL_REF - || GET_CODE (XEXP (new, 0)) == LABEL_REF) - && GET_CODE (XEXP (new, 1)) == CONST_INT) - new = gen_rtx_CONST (mode, new); } break; Index: simplify-rtx.c =================================================================== --- simplify-rtx.c (revision 140055) +++ simplify-rtx.c (working copy) @@ -3625,7 +3625,7 @@ simplify_plus_minus (enum rtx_code code, tem = simplify_binary_operation (ncode, mode, tem_lhs, tem_rhs); if (tem && !CONSTANT_P (tem)) - tem = gen_rtx_CONST (GET_MODE (tem), tem); + tem = plus_constant (tem, 0); } else tem = simplify_binary_operation (ncode, mode, lhs, rhs); @@ -3690,7 +3690,7 @@ simplify_plus_minus (enum rtx_code code, && GET_CODE (ops[i].op) == GET_CODE (ops[i - 1].op)) { ops[i - 1].op = gen_rtx_MINUS (mode, ops[i - 1].op, ops[i].op); - ops[i - 1].op = gen_rtx_CONST (mode, ops[i - 1].op); + ops[i - 1].op = plus_constant (ops[i - 1].op, 0); if (i < n_ops - 1) ops[i] = ops[i + 1]; n_ops--; @@ -5247,7 +5247,7 @@ simplify_subreg (enum machine_mode outer && GET_MODE_BITSIZE (innermode) >= (2 * GET_MODE_BITSIZE (outermode)) && GET_CODE (XEXP (op, 1)) == CONST_INT && (INTVAL (XEXP (op, 1)) & (GET_MODE_BITSIZE (outermode) - 1)) == 0 - && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (innermode) + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (innermode) && byte == subreg_lowpart_offset (outermode, innermode)) { int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT; Index: explow.c =================================================================== --- explow.c (revision 134435) +++ explow.c (working copy) @@ -83,9 +83,6 @@ plus_constant (rtx x, HOST_WIDE_INT c) rtx tem; int all_constant = 0; - if (c == 0) - return x; - restart: code = GET_CODE (x);