Hi:
  Sorry for Incomplete test for my last patch at
https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555948.html.
  This patch should fix invalid address introduced by special memory constraint.
  Bootstrap is ok, regression test is ok for make check
RUNTESTFLAGS="--target_board='unix{-m32,}'"

gcc/ChangeLog
        PR target/97532
        * gcc/lra-constraints.c (valid_address_p): Handle operand of
        special memory constraint.
        (process_address_1): Ditto.

--
BR,
Hongtao
From 720175c83f65b3dfc55f50bc3194c685d15ca003 Mon Sep 17 00:00:00 2001
From: liuhongt <hongtao.liu@intel.com>
Date: Mon, 26 Oct 2020 20:45:23 +0800
Subject: [PATCH 1/2] Fix invalid address for special_memory_constraint.

gcc/ChangeLog
	PR target/97532
	* gcc/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 b5c010d5030..9b94e0f210b 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.18.1

Reply via email to