aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir N. Makarov <vmakarov@redhat.com>2021-02-24 13:54:10 -0500
committerVladimir N. Makarov <vmakarov@redhat.com>2021-02-24 13:57:45 -0500
commitb6680c2084521d2612c3a08aa01b274078c4f3e3 (patch)
treeca3a63a64b37926ddc8fb28f657994a153154615
parent8265ab07f3bbeb672488fdfc6418e0bce89dff9c (diff)
downloadgcc-b6680c2084521d2612c3a08aa01b274078c4f3e3.zip
gcc-b6680c2084521d2612c3a08aa01b274078c4f3e3.tar.gz
gcc-b6680c2084521d2612c3a08aa01b274078c4f3e3.tar.bz2
[PR99123] inline-asm: Don't use decompose_mem_address to find used hard regs
Inline asm in question has empty constraint which means anything including memory with invalid address. To check used hard regs we used decompose_mem_address which assumes memory with valid address. The patch implements the same semantics without assuming valid addresses. gcc/ChangeLog: PR inline-asm/99123 * lra-constraints.c (uses_hard_regs_p): Don't use decompose_mem_address. gcc/testsuite/ChangeLog: PR inline-asm/99123 * gcc.target/i386/pr99123.c: New.
-rw-r--r--gcc/lra-constraints.c10
-rw-r--r--gcc/testsuite/gcc.target/i386/pr99123.c51
2 files changed, 51 insertions, 10 deletions
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 6a5aa41..51acf7f 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -1904,16 +1904,6 @@ uses_hard_regs_p (rtx x, HARD_REG_SET set)
return (x_hard_regno >= 0
&& overlaps_hard_reg_set_p (set, mode, x_hard_regno));
}
- if (MEM_P (x))
- {
- struct address_info ad;
-
- decompose_mem_address (&ad, x);
- if (ad.base_term != NULL && uses_hard_regs_p (*ad.base_term, set))
- return true;
- if (ad.index_term != NULL && uses_hard_regs_p (*ad.index_term, set))
- return true;
- }
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
diff --git a/gcc/testsuite/gcc.target/i386/pr99123.c b/gcc/testsuite/gcc.target/i386/pr99123.c
new file mode 100644
index 0000000..4f32547
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr99123.c
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+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;
+}