Fix invalid address for special_memory_constraint.
authorliuhongt <hongtao.liu@intel.com>
Mon, 26 Oct 2020 12:45:23 +0000 (20:45 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 4 Nov 2020 05:06:08 +0000 (13:06 +0800)
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

index fea1ef5..22e7075 100644 (file)
@@ -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));