[PR99378] LRA: Skip decomposing address for asm insn operand with unknown constraint.
authorVladimir N. Makarov <vmakarov@redhat.com>
Fri, 5 Mar 2021 16:41:25 +0000 (11:41 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Fri, 5 Mar 2021 16:44:06 +0000 (11:44 -0500)
  Function get_constraint_type returns CT__UNKNOWN for empty constraint
and CT_FIXED_FORM for "X".  So process_address_1 skipped
decompose_mem_address only for "X" constraint.  To do the same for empty
constraint, skip decompose_mem_address for CT__UNKNOWN.

gcc/ChangeLog:

PR target/99378
* lra-constraints.c (process_address_1): Skip decomposing address
for asm insn operand with unknown constraint.

gcc/testsuite/ChangeLog:

PR target/99378
* gcc.target/i386/pr99123-2.c: New.

gcc/lra-constraints.c
gcc/testsuite/gcc.target/i386/pr99123-2.c [new file with mode: 0644]

index 51acf7f..9253690 100644 (file)
@@ -3450,8 +3450,9 @@ process_address_1 (int nop, bool check_only_p,
      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)))
+               && (cn == CONSTRAINT__UNKNOWN
+                   || (get_constraint_type (cn) == CT_FIXED_FORM
+                       && constraint_satisfied_p (op, cn)))))
     decompose_mem_address (&ad, mem);
   else if (GET_CODE (op) == SUBREG
           && MEM_P (SUBREG_REG (op)))
diff --git a/gcc/testsuite/gcc.target/i386/pr99123-2.c b/gcc/testsuite/gcc.target/i386/pr99123-2.c
new file mode 100644 (file)
index 0000000..def4eae
--- /dev/null
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funroll-loops" } */
+
+static inline void *
+baz (void *s, unsigned long c, unsigned int count)
+{
+  int d0, d1;
+  __asm__ __volatile__ (""
+                        : "=&c" (d0), "=&D" (d1)
+                        :"a" (c), "q" (count), "0" (count / 4), "" ((long) s)   /// "1"
+                        :"memory");
+  return s;
+}
+
+struct A
+{
+  unsigned long *a;
+};
+
+inline static void *
+bar (struct A *x, int y)
+{
+  char *ptr;
+
+  ptr = (void *) x->a[y >> 12];
+  ptr += y % (1UL << 12);
+  return (void *) ptr;
+}
+
+int
+foo (struct A *x, unsigned int *y, int z, int u)
+{
+  int a, b, c, d, e;
+
+  z += *y;
+  c = z + u;
+  a = (z >> 12) + 1;
+  do
+    {
+      b = (a << 12);
+      d = b - z;
+      e = c - z;
+      if (e < d)
+        d = e;
+      baz (bar (x, z), 0, d);
+      z = b;
+      a++;
+    }
+  while (z < c);
+  return 0;
+}