From db8b3e148d5cc5358cd48886e5334bd50d2d3317 Mon Sep 17 00:00:00 2001 From: liuhongt Date: Mon, 26 Oct 2020 20:45:23 +0800 Subject: [PATCH] Fix invalid address for special_memory_constraint. gcc/ChangeLog PR target/97532 * lra-constraints.c (valid_address_p): Handle operand of special memory constraint. (process_address_1): Ditto. --- gcc/lra-constraints.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index fea1ef5d144..22e7075c4a5 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -406,8 +406,10 @@ valid_address_p (rtx op, struct address_info *ad, address_eliminator eliminator (ad); /* Allow a memory OP if it matches CONSTRAINT, even if CONSTRAINT is more - forgiving than "m". */ - if (MEM_P (op) + forgiving than "m". + Need to extract memory from op for special memory constraint, + i.e. bcst_mem_operand in i386 backend. */ + if (MEM_P (extract_mem_from_operand (op)) && (insn_extra_memory_constraint (constraint) || insn_extra_special_memory_constraint (constraint)) && constraint_satisfied_p (op, constraint)) @@ -3427,13 +3429,14 @@ process_address_1 (int nop, bool check_only_p, rtx new_reg; HOST_WIDE_INT scale; rtx op = *curr_id->operand_loc[nop]; + rtx mem = extract_mem_from_operand (op); const char *constraint = curr_static_id->operand[nop].constraint; enum constraint_num cn = lookup_constraint (constraint); bool change_p = false; - if (MEM_P (op) - && GET_MODE (op) == BLKmode - && GET_CODE (XEXP (op, 0)) == SCRATCH) + if (MEM_P (mem) + && GET_MODE (mem) == BLKmode + && GET_CODE (XEXP (mem, 0)) == SCRATCH) return false; if (insn_extra_address_constraint (cn) @@ -3446,12 +3449,14 @@ process_address_1 (int nop, bool check_only_p, && curr_static_id->operand[nop].is_address) decompose_lea_address (&ad, curr_id->operand_loc[nop]); /* Do not attempt to decompose arbitrary addresses generated by combine - for asm operands with loose constraints, e.g 'X'. */ - else if (MEM_P (op) + for asm operands with loose constraints, e.g 'X'. + Need to extract memory from op for special memory constraint, + i.e. bcst_mem_operand in i386 backend. */ + else if (MEM_P (mem) && !(INSN_CODE (curr_insn) < 0 && get_constraint_type (cn) == CT_FIXED_FORM && constraint_satisfied_p (op, cn))) - decompose_mem_address (&ad, op); + decompose_mem_address (&ad, mem); else if (GET_CODE (op) == SUBREG && MEM_P (SUBREG_REG (op))) decompose_mem_address (&ad, SUBREG_REG (op)); -- 2.30.2