From dbb138cef6cf3587d60d9bdfa273a605be9ef18d Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Wed, 15 Oct 2003 14:07:57 +0000 Subject: [PATCH] re PR target/12598 (Invalid size optimization on volatile memory reference) PR target/12598 * config/cris/cris.md (define_split "*mov_sidesi_biap_mem"+1) (define_splits "*mov_sidesi_mem"+1, "casesi"+9, +10, +11, +12): Use cris_mem_op and replace_equiv_address, not gen_rtx_MEM. ("call", "call_value", define_split "*mov_sidesi_mem"+19, +20) (define_split "*mov_sidesi_mem"+21, +22, +23, +24, +25, +26, +27) (define_split "*mov_sidesi_mem"+28, +29, +30): Use replace_equiv_address, not gen_rtx_MEM. * config/cris/cris.c (cris_mem_op): New match_operator function. * config/cris/cris.h (PREDICATE_CODES): Add cris_mem_op. From-SVN: r72521 --- gcc/ChangeLog | 13 +++++ gcc/config/cris/cris.c | 17 +++++- gcc/config/cris/cris.h | 2 + gcc/config/cris/cris.md | 117 +++++++++++++++++++++------------------- 4 files changed, 92 insertions(+), 57 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 55da6eeda59..376a23d7f8a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2003-10-15 Hans-Peter Nilsson + + PR target/12598 + * config/cris/cris.md (define_split "*mov_sidesi_biap_mem"+1) + (define_splits "*mov_sidesi_mem"+1, "casesi"+9, +10, +11, +12): + Use cris_mem_op and replace_equiv_address, not gen_rtx_MEM. + ("call", "call_value", define_split "*mov_sidesi_mem"+19, +20) + (define_split "*mov_sidesi_mem"+21, +22, +23, +24, +25, +26, +27) + (define_split "*mov_sidesi_mem"+28, +29, +30): Use + replace_equiv_address, not gen_rtx_MEM. + * config/cris/cris.c (cris_mem_op): New match_operator function. + * config/cris/cris.h (PREDICATE_CODES): Add cris_mem_op. + 2003-10-15 Bernardo Innocenti * config/m68k/m68k.h (MASK_SEP_DATA, TARGET_SEP_DATA, diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 2114f41040f..79b194b2d95 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -374,6 +374,19 @@ cris_plus_or_bound_operator (rtx x, enum machine_mode mode) (GET_MODE (x) == mode && (code == UMIN || code == PLUS)); } +/* Used as an operator to get a handle on a already-known-valid MEM rtx:es + (no need to validate the address), where some address expression parts + have their own match_operand. */ + +int +cris_mem_op (rtx x, enum machine_mode mode) +{ + if (mode == VOIDmode) + mode = GET_MODE (x); + + return GET_MODE (x) == mode && GET_CODE (x) == MEM; +} + /* Since with -fPIC, not all symbols are valid PIC symbols or indeed general_operands, we have to have a predicate that matches it for the "movsi" expander. */ @@ -1962,8 +1975,8 @@ cris_notice_update_cc (rtx exp, rtx insn) value1=rz and value2=[rx] */ cc_status.value1 = XEXP (XVECEXP (exp, 0, 0), 0); cc_status.value2 - = gen_rtx_MEM (GET_MODE (XEXP (XVECEXP (exp, 0, 0), 0)), - XEXP (XVECEXP (exp, 0, 1), 0)); + = replace_equiv_address (XEXP (XVECEXP (exp, 0, 0), 1), + XEXP (XVECEXP (exp, 0, 1), 0)); cc_status.flags = 0; /* Huh? A side-effect cannot change the destination diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index 0dc57f4a141..288be199713 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -1613,6 +1613,8 @@ call_ ## FUNC (void) \ {ZERO_EXTEND, SIGN_EXTEND}}, \ {"cris_plus_or_bound_operator", \ {PLUS, UMIN}}, \ + {"cris_mem_op", \ + {MEM}}, \ {"cris_bdap_operand", \ {SUBREG, REG, LABEL_REF, SYMBOL_REF, MEM, CONST_INT, \ CONST_DOUBLE, CONST, SIGN_EXTEND}}, \ diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index 6be28eabb01..ea347fd74fa 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -640,10 +640,12 @@ (define_split [(parallel - [(set (mem (plus:SI - (mult:SI (match_operand:SI 0 "register_operand" "") - (match_operand:SI 1 "const_int_operand" "")) - (match_operand:SI 2 "register_operand" ""))) + [(set (match_operator + 6 "cris_mem_op" + [(plus:SI + (mult:SI (match_operand:SI 0 "register_operand" "") + (match_operand:SI 1 "const_int_operand" "")) + (match_operand:SI 2 "register_operand" ""))]) (match_operand 3 "register_operand" "")) (set (match_operand:SI 4 "register_operand" "") (plus:SI (mult:SI (match_dup 0) @@ -657,11 +659,12 @@ (match_dup 1)) (match_dup 4)))] "operands[5] - = gen_rtx_MEM (GET_MODE (operands[3]), - gen_rtx_PLUS (SImode, - gen_rtx_MULT (SImode, - operands[0], operands[1]), - operands[2]));") + = replace_equiv_address (operands[6], + gen_rtx_PLUS (SImode, + gen_rtx_MULT (SImode, + operands[0], + operands[1]), + operands[2]));") ;; move.s rx,[ry=rz+i] ;; FIXME: These could have anonymous mode for operand 2. @@ -747,9 +750,11 @@ (define_split [(parallel - [(set (mem (plus:SI - (match_operand:SI 0 "cris_bdap_operand" "") - (match_operand:SI 1 "cris_bdap_operand" ""))) + [(set (match_operator + 4 "cris_mem_op" + [(plus:SI + (match_operand:SI 0 "cris_bdap_operand" "") + (match_operand:SI 1 "cris_bdap_operand" ""))]) (match_operand 2 "register_operand" "")) (set (match_operand:SI 3 "register_operand" "") (plus:SI (match_dup 0) (match_dup 1)))])] @@ -757,9 +762,7 @@ [(set (match_dup 4) (match_dup 2)) (set (match_dup 3) (match_dup 0)) (set (match_dup 3) (plus:SI (match_dup 3) (match_dup 1)))] - "operands[4] - = gen_rtx_MEM (GET_MODE (operands[2]), - gen_rtx_PLUS (SImode, operands[0], operands[1]));") + "") ;; Clear memory side-effect patterns. It is hard to get to the mode if ;; the MEM was anonymous, so there will be one for each mode. @@ -3833,7 +3836,7 @@ else abort (); - operands[0] = gen_rtx_MEM (GET_MODE (operands[0]), op0); + operands[0] = replace_equiv_address (operands[0], op0); } } }") @@ -3898,7 +3901,7 @@ else abort (); - operands[1] = gen_rtx_MEM (GET_MODE (operands[1]), op1); + operands[1] = replace_equiv_address (operands[1], op1); } } }") @@ -4201,10 +4204,12 @@ (define_split [(parallel [(set (match_operand 0 "register_operand" "") - (mem (plus:SI - (mult:SI (match_operand:SI 1 "register_operand" "") - (match_operand:SI 2 "const_int_operand" "")) - (match_operand:SI 3 "register_operand" "")))) + (match_operator + 6 "cris_mem_op" + [(plus:SI + (mult:SI (match_operand:SI 1 "register_operand" "") + (match_operand:SI 2 "const_int_operand" "")) + (match_operand:SI 3 "register_operand" ""))])) (set (match_operand:SI 4 "register_operand" "") (plus:SI (mult:SI (match_dup 1) (match_dup 2)) @@ -4214,16 +4219,17 @@ [(set (match_dup 4) (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3))) (set (match_dup 0) (match_dup 5))] - "operands[5] = gen_rtx_MEM (GET_MODE (operands[0]), operands[3]);") + "operands[5] = replace_equiv_address (operands[6], operands[3]);") ;; move.S1 [rx=rx+i],ry (define_split [(parallel [(set (match_operand 0 "register_operand" "") - (mem - (plus:SI (match_operand:SI 1 "cris_bdap_operand" "") - (match_operand:SI 2 "cris_bdap_operand" "")))) + (match_operator + 5 "cris_mem_op" + [(plus:SI (match_operand:SI 1 "cris_bdap_operand" "") + (match_operand:SI 2 "cris_bdap_operand" ""))])) (set (match_operand:SI 3 "register_operand" "") (plus:SI (match_dup 1) (match_dup 2)))])] @@ -4231,17 +4237,19 @@ || rtx_equal_p (operands[3], operands[2]))" [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2))) (set (match_dup 0) (match_dup 4))] - "operands[4] = gen_rtx_MEM (GET_MODE (operands[0]), operands[3]);") + "operands[4] = replace_equiv_address (operands[5], operands[3]);") ;; move.S1 ry,[rx=rx+rz.S2] (define_split [(parallel - [(set (mem (plus:SI - (mult:SI (match_operand:SI 0 "register_operand" "") - (match_operand:SI 1 "const_int_operand" "")) - (match_operand:SI 2 "register_operand" ""))) - (match_operand 3 "register_operand" "")) + [(set (match_operator + 6 "cris_mem_op" + [(plus:SI + (mult:SI (match_operand:SI 0 "register_operand" "") + (match_operand:SI 1 "const_int_operand" "")) + (match_operand:SI 2 "register_operand" ""))]) + (match_operand 3 "register_operand" "")) (set (match_operand:SI 4 "register_operand" "") (plus:SI (mult:SI (match_dup 0) (match_dup 1)) @@ -4251,16 +4259,17 @@ [(set (match_dup 4) (plus:SI (mult:SI (match_dup 0) (match_dup 1)) (match_dup 2))) (set (match_dup 5) (match_dup 3))] - "operands[5] = gen_rtx_MEM (GET_MODE (operands[3]), operands[4]);") + "operands[5] = replace_equiv_address (operands[6], operands[4]);") ;; move.S1 ry,[rx=rx+i] (define_split [(parallel - [(set (mem - (plus:SI (match_operand:SI 0 "cris_bdap_operand" "") - (match_operand:SI 1 "cris_bdap_operand" ""))) - (match_operand 2 "register_operand" "")) + [(set (match_operator + 6 "cris_mem_op" + [(plus:SI (match_operand:SI 0 "cris_bdap_operand" "") + (match_operand:SI 1 "cris_bdap_operand" ""))]) + (match_operand 2 "register_operand" "")) (set (match_operand:SI 3 "register_operand" "") (plus:SI (match_dup 0) (match_dup 1)))])] @@ -4268,7 +4277,7 @@ || rtx_equal_p (operands[3], operands[1]))" [(set (match_dup 3) (plus:SI (match_dup 0) (match_dup 1))) (set (match_dup 5) (match_dup 2))] - "operands[5] = gen_rtx_MEM (GET_MODE (operands[2]), operands[3]);") + "operands[5] = replace_equiv_address (operands[6], operands[3]);") ;; clear.d [rx=rx+rz.S2] @@ -4402,8 +4411,7 @@ [(set (match_dup 4) (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3))) (set (match_dup 0) (match_op_dup 5 [(match_dup 6)]))] - "operands[6] = gen_rtx_MEM (GET_MODE (XEXP (operands[5],0)), - operands[4]);") + "operands[6] = replace_equiv_address (XEXP (operands[5], 0), operands[4]);") ;; mov(s|u).S1 [rx=rx+i],ry @@ -4422,8 +4430,7 @@ || rtx_equal_p (operands[2], operands[3]))" [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2))) (set (match_dup 0) (match_op_dup 4 [(match_dup 5)]))] - "operands[5] = gen_rtx_MEM (GET_MODE (XEXP (operands[4], 0)), - operands[3]);") + "operands[5] = replace_equiv_address (XEXP (operands[4], 0), operands[3]);") ;; op.S1 [rx=rx+i],ry @@ -4443,7 +4450,7 @@ || rtx_equal_p (operands[4], operands[3]))" [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3))) (set (match_dup 0) (match_op_dup 5 [(match_dup 1) (match_dup 6)]))] - "operands[6] = gen_rtx_MEM (GET_MODE (operands[0]), operands[4]);") + "operands[6] = replace_equiv_address (XEXP (operands[5], 1), operands[4]);") ;; op.S1 [rx=rx+rz.S2],ry @@ -4467,7 +4474,7 @@ [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3)) (match_dup 4))) (set (match_dup 0) (match_op_dup 6 [(match_dup 1) (match_dup 7)]))] - "operands[7] = gen_rtx_MEM (GET_MODE (operands[0]), operands[5]);") + "operands[7] = replace_equiv_address (XEXP (operands[6], 1), operands[5]);") ;; op.S1 [rx=rx+rz.S2],ry (swapped) @@ -4491,7 +4498,7 @@ [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3)) (match_dup 4))) (set (match_dup 0) (match_op_dup 6 [(match_dup 7) (match_dup 1)]))] - "operands[7] = gen_rtx_MEM (GET_MODE (operands[0]), operands[5]);") + "operands[7] = replace_equiv_address (XEXP (operands[6], 0), operands[5]);") ;; op.S1 [rx=rx+i],ry (swapped) @@ -4511,7 +4518,7 @@ || rtx_equal_p (operands[4], operands[3]))" [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3))) (set (match_dup 0) (match_op_dup 5 [(match_dup 6) (match_dup 1)]))] - "operands[6] = gen_rtx_MEM (GET_MODE (operands[0]), operands[4]);") + "operands[6] = replace_equiv_address (XEXP (operands[5], 0), operands[4]);") ;; op(s|u).S1 [rx=rx+rz.S2],ry @@ -4538,8 +4545,8 @@ (match_dup 4))) (set (match_dup 0) (match_op_dup 6 [(match_dup 1) (match_dup 8)]))] "operands[8] = gen_rtx (GET_CODE (operands[7]), GET_MODE (operands[7]), - gen_rtx_MEM (GET_MODE (XEXP (operands[7], 0)), - operands[5]));") + replace_equiv_address (XEXP (operands[7], 0), + operands[5]));") ;; op(s|u).S1 [rx=rx+i],ry @@ -4563,8 +4570,8 @@ [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3))) (set (match_dup 0) (match_op_dup 5 [(match_dup 1) (match_dup 7)]))] "operands[7] = gen_rtx (GET_CODE (operands[6]), GET_MODE (operands[6]), - gen_rtx_MEM (GET_MODE (XEXP (operands[6], 0)), - operands[4]));") + replace_equiv_address (XEXP (operands[6], 0), + operands[4]));") ;; op(s|u).S1 [rx=rx+rz.S2],ry (swapped, plus or bound) @@ -4590,8 +4597,8 @@ (match_dup 4))) (set (match_dup 0) (match_op_dup 6 [(match_dup 8) (match_dup 1)]))] "operands[8] = gen_rtx (GET_CODE (operands[6]), GET_MODE (operands[6]), - gen_rtx_MEM (GET_MODE (XEXP (operands[6], 0)), - operands[5]));") + replace_equiv_address (XEXP (operands[6], 0), + operands[5]));") ;; op(s|u).S1 [rx=rx+i],ry (swapped, plus or bound) @@ -4614,8 +4621,8 @@ [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3))) (set (match_dup 0) (match_op_dup 6 [(match_dup 7) (match_dup 1)]))] "operands[7] = gen_rtx (GET_CODE (operands[5]), GET_MODE (operands[5]), - gen_rtx_MEM (GET_MODE (XEXP (operands[5], 0)), - operands[4]));") + replace_equiv_address (XEXP (operands[5], 0), + operands[4]));") ;; Splits for addressing prefixes that have no side-effects, so we can ;; fill a delay slot. Never split if we lose something, though. @@ -4643,7 +4650,7 @@ [(set (match_dup 2) (match_dup 4)) (set (match_dup 0) (match_dup 3))] "operands[2] = gen_rtx_REG (Pmode, REGNO (operands[0])); - operands[3] = gen_rtx_MEM (GET_MODE (operands[0]), operands[2]); + operands[3] = replace_equiv_address (operands[1], operands[2]); operands[4] = XEXP (operands[1], 0);") ;; As the above, but MOVS and MOVU. @@ -4661,7 +4668,7 @@ [(set (match_dup 2) (match_dup 5)) (set (match_dup 0) (match_op_dup 4 [(match_dup 3)]))] "operands[2] = gen_rtx_REG (Pmode, REGNO (operands[0])); - operands[3] = gen_rtx_MEM (GET_MODE (XEXP (operands[4], 0)), operands[2]); + operands[3] = replace_equiv_address (XEXP (operands[4], 0), operands[2]); operands[5] = XEXP (operands[1], 0);") ;; Various peephole optimizations.