diff mbox series

[03/11] aarch64, testsuite: Fix up auto-init-padding tests

Message ID ZVZaXJY/K04w2ojw@arm.com
State New
Headers show
Series aarch64: Rework ldp/stp patterns, add new ldp/stp pass | expand

Commit Message

Alex Coplan Nov. 16, 2023, 6:07 p.m. UTC
The tests currently depending on memcpy lowering forming stps at -O0,
but we no longer want to form stps during memcpy lowering, but instead
in the load/store pair fusion pass.

This patch therefore tweaks affected tests to enable optimizations
(-O1), and adjusts the tests to avoid parts of the structures being
optimized away where necessary.

OK for trunk?

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/auto-init-padding-1.c: Add -O to options,
	adjust test to work with optimizations enabled.
	* gcc.target/aarch64/auto-init-padding-2.c: Add -O to options.
	* gcc.target/aarch64/auto-init-padding-3.c: Add -O to options,
	adjust test to work with optimizations enabled.
	* gcc.target/aarch64/auto-init-padding-4.c: Likewise.
	* gcc.target/aarch64/auto-init-padding-9.c: Likewise.
---
 gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c | 8 +++++---
 gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c | 2 +-
 gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c | 7 ++++---
 gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c | 4 ++--
 gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c | 7 ++++---
 5 files changed, 16 insertions(+), 12 deletions(-)

Comments

Richard Sandiford Nov. 21, 2023, 12:04 p.m. UTC | #1
Alex Coplan <alex.coplan@arm.com> writes:
> The tests currently depending on memcpy lowering forming stps at -O0,
> but we no longer want to form stps during memcpy lowering, but instead
> in the load/store pair fusion pass.
>
> This patch therefore tweaks affected tests to enable optimizations
> (-O1), and adjusts the tests to avoid parts of the structures being
> optimized away where necessary.
>
> OK for trunk?
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/aarch64/auto-init-padding-1.c: Add -O to options,
> 	adjust test to work with optimizations enabled.
> 	* gcc.target/aarch64/auto-init-padding-2.c: Add -O to options.
> 	* gcc.target/aarch64/auto-init-padding-3.c: Add -O to options,
> 	adjust test to work with optimizations enabled.
> 	* gcc.target/aarch64/auto-init-padding-4.c: Likewise.
> 	* gcc.target/aarch64/auto-init-padding-9.c: Likewise.

OK, thanks.

Richard

> ---
>  gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c | 8 +++++---
>  gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c | 2 +-
>  gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c | 7 ++++---
>  gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c | 4 ++--
>  gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c | 7 ++++---
>  5 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c
> index c747ebdcdf7..7027454dc74 100644
> --- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c
> @@ -1,17 +1,19 @@
>  /* Verify zero initialization for structure type automatic variables with
>     padding.  */
>  /* { dg-do compile } */
> -/* { dg-options "-ftrivial-auto-var-init=zero" } */
> +/* { dg-options "-O -ftrivial-auto-var-init=zero" } */
>  
>  struct test_aligned {
>          int internal1;
>          long long internal2;
>  } __attribute__ ((aligned(64)));
>  
> -int foo ()
> +void bar (struct test_aligned *);
> +
> +void foo ()
>  {
>    struct test_aligned var;
> -  return var.internal1;
> +  bar(&var);
>  }
>  
>  /* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 2 } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c
> index 6e280904da1..d3b6591c9b0 100644
> --- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c
> +++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c
> @@ -1,7 +1,7 @@
>  /* Verify pattern initialization for structure type automatic variables with
>     padding.  */
>  /* { dg-do compile } */
> -/* { dg-options "-ftrivial-auto-var-init=pattern" } */
> +/* { dg-options "-O -ftrivial-auto-var-init=pattern" } */
>  
>  struct test_aligned {
>          int internal1;
> diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c
> index 9ddea58b468..aad4bb8944f 100644
> --- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c
> +++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c
> @@ -1,7 +1,7 @@
>  /* Verify zero initialization for nested structure type automatic variables with
>     padding.  */
>  /* { dg-do compile } */
> -/* { dg-options "-ftrivial-auto-var-init=zero" } */
> +/* { dg-options "-O -ftrivial-auto-var-init=zero" } */
>  
>  struct test_aligned {
>          unsigned internal1;
> @@ -16,11 +16,12 @@ struct test_big_hole {
>          struct test_aligned four;
>  } __attribute__ ((aligned(64)));
>  
> +void bar (struct test_big_hole *);
>  
> -int foo ()
> +void foo ()
>  {
>    struct test_big_hole var;
> -  return var.four.internal1;
> +  bar (&var);
>  }
>  
>  /* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 4 } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c
> index 75bba82ed34..efd310f054d 100644
> --- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c
> +++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c
> @@ -1,7 +1,7 @@
>  /* Verify pattern initialization for nested structure type automatic variables with
>     padding.  */
>  /* { dg-do compile } */
> -/* { dg-options "-ftrivial-auto-var-init=pattern" } */
> +/* { dg-options "-O -ftrivial-auto-var-init=pattern" } */
>  
>  struct test_aligned {
>          unsigned internal1;
> @@ -23,4 +23,4 @@ int foo ()
>    return var.four.internal1;
>  }
>  
> -/* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 5 } } */
> +/* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 4 } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c
> index 0f1930f813e..64ed8f11fe6 100644
> --- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c
> +++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c
> @@ -1,7 +1,7 @@
>  /* Verify zero initialization for array type with structure element with
>     padding.  */ 
>  /* { dg-do compile } */
> -/* { dg-options "-ftrivial-auto-var-init=zero" } */
> +/* { dg-options "-O -ftrivial-auto-var-init=zero" } */
>  
>  struct test_trailing_hole {
>          int one;
> @@ -11,11 +11,12 @@ struct test_trailing_hole {
>          /* "sizeof(unsigned long) - 1" byte padding hole here. */
>  };
>  
> +void bar (void *);
>  
> -int foo ()
> +void foo ()
>  {
>    struct test_trailing_hole var[10]; 
> -  return var[2].four;
> +  bar (var);
>  }
>  
>  /* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 5 } } */
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c
index c747ebdcdf7..7027454dc74 100644
--- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c
+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-1.c
@@ -1,17 +1,19 @@ 
 /* Verify zero initialization for structure type automatic variables with
    padding.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=zero" } */
+/* { dg-options "-O -ftrivial-auto-var-init=zero" } */
 
 struct test_aligned {
         int internal1;
         long long internal2;
 } __attribute__ ((aligned(64)));
 
-int foo ()
+void bar (struct test_aligned *);
+
+void foo ()
 {
   struct test_aligned var;
-  return var.internal1;
+  bar(&var);
 }
 
 /* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 2 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c
index 6e280904da1..d3b6591c9b0 100644
--- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c
+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-2.c
@@ -1,7 +1,7 @@ 
 /* Verify pattern initialization for structure type automatic variables with
    padding.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=pattern" } */
+/* { dg-options "-O -ftrivial-auto-var-init=pattern" } */
 
 struct test_aligned {
         int internal1;
diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c
index 9ddea58b468..aad4bb8944f 100644
--- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c
+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-3.c
@@ -1,7 +1,7 @@ 
 /* Verify zero initialization for nested structure type automatic variables with
    padding.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=zero" } */
+/* { dg-options "-O -ftrivial-auto-var-init=zero" } */
 
 struct test_aligned {
         unsigned internal1;
@@ -16,11 +16,12 @@  struct test_big_hole {
         struct test_aligned four;
 } __attribute__ ((aligned(64)));
 
+void bar (struct test_big_hole *);
 
-int foo ()
+void foo ()
 {
   struct test_big_hole var;
-  return var.four.internal1;
+  bar (&var);
 }
 
 /* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 4 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c
index 75bba82ed34..efd310f054d 100644
--- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c
+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-4.c
@@ -1,7 +1,7 @@ 
 /* Verify pattern initialization for nested structure type automatic variables with
    padding.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=pattern" } */
+/* { dg-options "-O -ftrivial-auto-var-init=pattern" } */
 
 struct test_aligned {
         unsigned internal1;
@@ -23,4 +23,4 @@  int foo ()
   return var.four.internal1;
 }
 
-/* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 5 } } */
+/* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 4 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c
index 0f1930f813e..64ed8f11fe6 100644
--- a/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c
+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-padding-9.c
@@ -1,7 +1,7 @@ 
 /* Verify zero initialization for array type with structure element with
    padding.  */ 
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=zero" } */
+/* { dg-options "-O -ftrivial-auto-var-init=zero" } */
 
 struct test_trailing_hole {
         int one;
@@ -11,11 +11,12 @@  struct test_trailing_hole {
         /* "sizeof(unsigned long) - 1" byte padding hole here. */
 };
 
+void bar (void *);
 
-int foo ()
+void foo ()
 {
   struct test_trailing_hole var[10]; 
-  return var[2].four;
+  bar (var);
 }
 
 /* { dg-final { scan-assembler-times {stp\tq[0-9]+, q[0-9]+,} 5 } } */