testsuite: Add testcase for already fixed PR [PR109362]
authorJakub Jelinek <jakub@redhat.com>
Sat, 1 Apr 2023 07:00:22 +0000 (09:00 +0200)
committerJakub Jelinek <jakub@redhat.com>
Sat, 1 Apr 2023 07:00:22 +0000 (09:00 +0200)
This PR got fixed with r13-137.
Add a testcase to make sure it doesn't reappear.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109362
* gcc.target/i386/pr109362.c: New test.

gcc/testsuite/gcc.target/i386/pr109362.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.target/i386/pr109362.c b/gcc/testsuite/gcc.target/i386/pr109362.c
new file mode 100644 (file)
index 0000000..0e44dae
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/109362 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2 -masm=att" } */
+/* Ensure we don't waste a register set to %rdi + 8.  */
+/* { dg-final { scan-assembler "\tmovq\t\\\(%rdi\\\), %r" } } */
+/* { dg-final { scan-assembler "\tmovq\t8\\\(%rdi\\\), %r" } } */
+
+struct S { long a, b; };
+
+int
+foo (struct S *v)
+{
+  while (1)
+    {
+      __atomic_load_n (&v->a, __ATOMIC_ACQUIRE);
+      if (__atomic_load_n (&v->b, __ATOMIC_ACQUIRE))
+       return 1;
+    }
+}