Don't extract memory from operand for normal memory constraint.
authorliuhongt <hongtao.liu@intel.com>
Mon, 26 Oct 2020 12:46:42 +0000 (20:46 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 4 Nov 2020 05:06:32 +0000 (13:06 +0800)
gcc/ChangeLog
PR target/97540
* ira.c: (ira_setup_alts): Extract memory from operand only
for special memory constraint.
* recog.c (asm_operand_ok): Ditto.
* lra-constraints.c (process_alt_operands): MEM_P is
required for normal memory constraint.

gcc/testsuite/ChangeLog
* gcc.target/i386/pr97540.c: New test.

gcc/ira.c
gcc/lra-constraints.c
gcc/recog.c
gcc/testsuite/gcc.target/i386/pr97540.c [new file with mode: 0644]

index bc94e15a50e5548188f6bf7626da5dafeebda782..050405f183311cc7f3917046b495dc15b64f482c 100644 (file)
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -1845,6 +1845,7 @@ ira_setup_alts (rtx_insn *insn)
                  default:
                    {
                      enum constraint_num cn = lookup_constraint (p);
+                     rtx mem = NULL;
                      switch (get_constraint_type (cn))
                        {
                        case CT_REGISTER:
@@ -1867,8 +1868,12 @@ ira_setup_alts (rtx_insn *insn)
                          goto op_success;
 
                        case CT_MEMORY:
+                         mem = op;
+                         /* Fall through.  */
                        case CT_SPECIAL_MEMORY:
-                         if (MEM_P (extract_mem_from_operand (op)))
+                         if (!mem)
+                           mem = extract_mem_from_operand (op);
+                         if (MEM_P (mem))
                            goto op_success;
                          win_p = true;
                          break;
index 22e7075c4a51c8c898a43a5f7631a8c87828211e..fbc47baa998cc2b5a1d90e2ba029b07c95221f32 100644 (file)
@@ -2428,7 +2428,8 @@ process_alt_operands (int only_alternative)
                      break;
 
                    case CT_MEMORY:
-                     if (satisfies_memory_constraint_p (op, cn))
+                     if (MEM_P (op)
+                         && satisfies_memory_constraint_p (op, cn))
                        win = true;
                      else if (spilled_pseudo_p (op))
                        win = true;
index 45a52e284e1c6cbbedaaedc13d5bd66750d0002a..6d8b7d560eed7f4785c3c870f641240787d4dbb3 100644 (file)
@@ -1794,6 +1794,7 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints)
          /* FALLTHRU */
        default:
          cn = lookup_constraint (constraint);
+         rtx mem = NULL;
          switch (get_constraint_type (cn))
            {
            case CT_REGISTER:
@@ -1812,10 +1813,13 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints)
              break;
 
            case CT_MEMORY:
+             mem = op;
+             /* Fall through.  */
            case CT_SPECIAL_MEMORY:
              /* Every memory operand can be reloaded to fit.  */
-             result = result || memory_operand (extract_mem_from_operand (op),
-                                                VOIDmode);
+             if (!mem)
+               mem = extract_mem_from_operand (op);
+             result = result || memory_operand (mem, VOIDmode);
              break;
 
            case CT_ADDRESS:
diff --git a/gcc/testsuite/gcc.target/i386/pr97540.c b/gcc/testsuite/gcc.target/i386/pr97540.c
new file mode 100644 (file)
index 0000000..20f8717
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int mt7615_add_interface_dev_0;
+int ffs(int x) { asm("" : : "rm"(x)); }
+int mt7615_add_interface() { ffs(~mt7615_add_interface_dev_0); }