testsuite: Fix c-c++-common/auto-init-* tests

Message ID 20210911080320.GA304296@tucnak
State New
Headers show
Series
  • testsuite: Fix c-c++-common/auto-init-* tests
Related show

Commit Message

Antony Polukhin via Gcc-patches Sept. 11, 2021, 8:03 a.m.
On Fri, Sep 03, 2021 at 02:47:11PM +0000, Qing Zhao via Gcc-patches wrote:
> > 2021-08-20  qing zhao  <qing.zhao@oracle.com>

> > 

> >        * c-c++-common/auto-init-1.c: New test.

> >        * c-c++-common/auto-init-10.c: New test.

> >        * c-c++-common/auto-init-11.c: New test.

> >        * c-c++-common/auto-init-12.c: New test.

> >        * c-c++-common/auto-init-13.c: New test.

> >        * c-c++-common/auto-init-14.c: New test.

> >        * c-c++-common/auto-init-15.c: New test.

> >        * c-c++-common/auto-init-16.c: New test.

> >        * c-c++-common/auto-init-2.c: New test.

> >        * c-c++-common/auto-init-3.c: New test.

> >        * c-c++-common/auto-init-4.c: New test.

> >        * c-c++-common/auto-init-5.c: New test.

> >        * c-c++-common/auto-init-6.c: New test.

> >        * c-c++-common/auto-init-7.c: New test.

> >        * c-c++-common/auto-init-8.c: New test.

> >        * c-c++-common/auto-init-9.c: New test.

> >        * c-c++-common/auto-init-esra.c: New test.

> >        * c-c++-common/auto-init-padding-1.c: New test.

> >        * c-c++-common/auto-init-padding-2.c: New test.

> >        * c-c++-common/auto-init-padding-3.c: New test.


This fails on many targets, e.g. i686-linux or x86_64-linux with -m32.

The main problem is hardcoding type sizes and structure layout expectations
that are valid only on some lp64 targets.
On ilp32 long and pointer are 32-bit, and there are targets that are neither
ilp32 nor lp64 and there even other sizes can't be taken for granted.
Also, long double depending on target and options is either 8, 12 or 16 byte
(the first one when it is the same as double, the second e.g. for ia32
extended long double (which is under the hood 10 byte), the last either
the same hw type on x86_64 or IBM double double or IEEE quad).
In the last test, one problem is that unsigned long is on ilp32 32-bit
instead of 64-bit, but even just changing to long long is not enough,
as long long in structures on ia32 is only 4 byte aligned instead of 8.

Tested on x86_64-linux -m32/-m64, ok for trunk?

Note, the gcc.dg/i386/auto-init* tests fail also, just don't have time to
deal with that right now, just try
make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*'
Guess some of those tests should be restricted to lp64 in there, others
where it might be easier to check all of lp64, x32 and ia32 code generation
could have different matches.  Wonder also about the aarch64 tests, there is
also -mabi=ilp32...
+FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3
+FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2
+FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\\t\\\\%xmm0, \\\\%xmm0 3
+FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1
+FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1
+FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\\\.long\\t0 14
+FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2
+FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1
+FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 2
+FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\)\\\\)" 3
+FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1
+FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2
+FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 2
+FAIL: gcc.target/i386/auto-init-padding-1.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-10.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-11.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-12.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-2.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\\t\\\\\$16,
+FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq
+FAIL: gcc.target/i386/auto-init-padding-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-5.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1
+FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\\t\\\\\$0, 2
+FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\\t\\\\\$0, 2
+FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq

2021-09-11  Jakub Jelinek  <jakub@redhat.com>

	* c-c++-common/auto-init-1.c: Enable test only on ilp32 or lp64
	targets, expect different long and pointer sizes between ilp32 and
	lp64.
	* c-c++-common/auto-init-2.c: Likewise.
	* c-c++-common/auto-init-3.c: Expect one of the common long double
	sizes (8/12/16 bytes) instead of hardcoding 16 bytes.
	* c-c++-common/auto-init-4.c: Likewise.
	* c-c++-common/auto-init-5.c: Expect one of the common
	_Complex long double sizes (16/24/32 bytes) instead of hardcoding 32
	bytes.
	* c-c++-common/auto-init-6.c: Likewise.
	* c-c++-common/auto-init-padding-1.c: Enable test only on ilp32 or lp64
	targets.
	(struct test_small_hole): Change type of four to unsigned long long
	and add aligned attribute.



	Jakub

Comments

Antony Polukhin via Gcc-patches Sept. 11, 2021, 11:45 a.m. | #1
On September 11, 2021 10:03:20 AM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>On Fri, Sep 03, 2021 at 02:47:11PM +0000, Qing Zhao via Gcc-patches wrote:

>> > 2021-08-20  qing zhao  <qing.zhao@oracle.com>

>> > 

>> >        * c-c++-common/auto-init-1.c: New test.

>> >        * c-c++-common/auto-init-10.c: New test.

>> >        * c-c++-common/auto-init-11.c: New test.

>> >        * c-c++-common/auto-init-12.c: New test.

>> >        * c-c++-common/auto-init-13.c: New test.

>> >        * c-c++-common/auto-init-14.c: New test.

>> >        * c-c++-common/auto-init-15.c: New test.

>> >        * c-c++-common/auto-init-16.c: New test.

>> >        * c-c++-common/auto-init-2.c: New test.

>> >        * c-c++-common/auto-init-3.c: New test.

>> >        * c-c++-common/auto-init-4.c: New test.

>> >        * c-c++-common/auto-init-5.c: New test.

>> >        * c-c++-common/auto-init-6.c: New test.

>> >        * c-c++-common/auto-init-7.c: New test.

>> >        * c-c++-common/auto-init-8.c: New test.

>> >        * c-c++-common/auto-init-9.c: New test.

>> >        * c-c++-common/auto-init-esra.c: New test.

>> >        * c-c++-common/auto-init-padding-1.c: New test.

>> >        * c-c++-common/auto-init-padding-2.c: New test.

>> >        * c-c++-common/auto-init-padding-3.c: New test.

>

>This fails on many targets, e.g. i686-linux or x86_64-linux with -m32.

>

>The main problem is hardcoding type sizes and structure layout expectations

>that are valid only on some lp64 targets.

>On ilp32 long and pointer are 32-bit, and there are targets that are neither

>ilp32 nor lp64 and there even other sizes can't be taken for granted.

>Also, long double depending on target and options is either 8, 12 or 16 byte

>(the first one when it is the same as double, the second e.g. for ia32

>extended long double (which is under the hood 10 byte), the last either

>the same hw type on x86_64 or IBM double double or IEEE quad).

>In the last test, one problem is that unsigned long is on ilp32 32-bit

>instead of 64-bit, but even just changing to long long is not enough,

>as long long in structures on ia32 is only 4 byte aligned instead of 8.

>

>Tested on x86_64-linux -m32/-m64, ok for trunk?


Ok. 

Thanks, 
Richard. 

>Note, the gcc.dg/i386/auto-init* tests fail also, just don't have time to

>deal with that right now, just try

>make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*'

>Guess some of those tests should be restricted to lp64 in there, others

>where it might be easier to check all of lp64, x32 and ia32 code generation

>could have different matches.  Wonder also about the aarch64 tests, there is

>also -mabi=ilp32...

>+FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3

>+FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2

>+FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\\t\\\\%xmm0, \\\\%xmm0 3

>+FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

>+FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1

>+FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\\\.long\\t0 14

>+FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2

>+FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1

>+FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 2

>+FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\)\\\\)" 3

>+FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

>+FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2

>+FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 2

>+FAIL: gcc.target/i386/auto-init-padding-1.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-10.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-11.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-12.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-2.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\\t\\\\\$16,

>+FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq

>+FAIL: gcc.target/i386/auto-init-padding-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-5.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

>+FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\\t\\\\\$0, 2

>+FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\\t\\\\\$0, 2

>+FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq

>

>2021-09-11  Jakub Jelinek  <jakub@redhat.com>

>

>	* c-c++-common/auto-init-1.c: Enable test only on ilp32 or lp64

>	targets, expect different long and pointer sizes between ilp32 and

>	lp64.

>	* c-c++-common/auto-init-2.c: Likewise.

>	* c-c++-common/auto-init-3.c: Expect one of the common long double

>	sizes (8/12/16 bytes) instead of hardcoding 16 bytes.

>	* c-c++-common/auto-init-4.c: Likewise.

>	* c-c++-common/auto-init-5.c: Expect one of the common

>	_Complex long double sizes (16/24/32 bytes) instead of hardcoding 32

>	bytes.

>	* c-c++-common/auto-init-6.c: Likewise.

>	* c-c++-common/auto-init-padding-1.c: Enable test only on ilp32 or lp64

>	targets.

>	(struct test_small_hole): Change type of four to unsigned long long

>	and add aligned attribute.

>

>--- gcc/testsuite/c-c++-common/auto-init-1.c.jj	2021-09-11 09:33:37.896331809 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-1.c	2021-09-11 09:37:05.108368101 +0200

>@@ -1,5 +1,5 @@

> /* Verify zero initialization for integer and pointer type automatic variables.  */

>-/* { dg-do compile } */

>+/* { dg-do compile { target { ilp32 || lp64 } } } */

> /* { dg-options "-ftrivial-auto-var-init=zero -fdump-tree-gimple" } */

> 

> #ifndef __cplusplus

>@@ -33,7 +33,9 @@ void foo()

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */

>+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */

>+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 2, 0\\)" "gimple" } } */

>--- gcc/testsuite/c-c++-common/auto-init-2.c.jj	2021-09-11 09:33:37.897331795 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-2.c	2021-09-11 09:38:10.908426977 +0200

>@@ -1,5 +1,5 @@

> /* Verify pattern initialization for integer and pointer type automatic variables.  */

>-/* { dg-do compile } */

>+/* { dg-do compile { target { ilp32 || lp64 } } } */

> /* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */

> 

> #ifndef __cplusplus

>@@ -33,7 +33,9 @@ void foo()

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */

>+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */

>+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 1, 0\\)" "gimple" } } */

>--- gcc/testsuite/c-c++-common/auto-init-3.c.jj	2021-09-11 09:33:37.897331795 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-3.c	2021-09-11 09:39:40.626143763 +0200

>@@ -16,4 +16,4 @@ long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 2, 0\\)" "gimple" } } */

>--- gcc/testsuite/c-c++-common/auto-init-4.c.jj	2021-09-11 09:33:37.897331795 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-4.c	2021-09-11 09:42:50.645427377 +0200

>@@ -16,4 +16,4 @@ long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 1, 0\\)" "gimple" } } */

>--- gcc/testsuite/c-c++-common/auto-init-5.c.jj	2021-09-11 09:33:37.897331795 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-5.c	2021-09-11 09:43:14.909080575 +0200

>@@ -17,5 +17,5 @@ _Complex long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(32, 2, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 2, 0\\)" "gimple" } } */

> 

>--- gcc/testsuite/c-c++-common/auto-init-6.c.jj	2021-09-11 09:33:37.897331795 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-6.c	2021-09-11 09:43:34.316803177 +0200

>@@ -17,5 +17,5 @@ _Complex long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */

>-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(32, 1, 0\\)" "gimple" } } */

>+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 1, 0\\)" "gimple" } } */

> 

>--- gcc/testsuite/c-c++-common/auto-init-padding-1.c.jj	2021-09-11 09:33:37.897331795 +0200

>+++ gcc/testsuite/c-c++-common/auto-init-padding-1.c	2021-09-11 09:48:21.651696258 +0200

>@@ -1,6 +1,6 @@

> /* Verify the padding initialization for pattern initialization, we always emit

>  * a call to __builtin_clear_padding to initialize the paddings to zero.  */

>-/* { dg-do compile } */

>+/* { dg-do compile { target { ilp32 || lp64 } } } */

> /* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */

> 

> 

>@@ -9,7 +9,7 @@ struct test_small_hole {

>   char two;

>   /* 3 byte padding hole here. */

>   int three;

>-  unsigned long four;

>+  unsigned long long four __attribute__((aligned (8)));

> };

> 

> extern void g (struct test_small_hole);

>

>

>	Jakub

>
Antony Polukhin via Gcc-patches Sept. 11, 2021, 4:58 p.m. | #2
Hi, Jakub,

Thanks a lot for your patch to the testing cases in c-c++-common. 
Actually I had a local fix too, and I planed to submitted it after I fixed all the failure for dg.target/i386 failures on different platforms..;-)


> On Sep 11, 2021, at 3:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:

> 

> On Fri, Sep 03, 2021 at 02:47:11PM +0000, Qing Zhao via Gcc-patches wrote:

>>> 2021-08-20  qing zhao  <qing.zhao@oracle.com>

>>> 

>>>       * c-c++-common/auto-init-1.c: New test.

>>>       * c-c++-common/auto-init-10.c: New test.

>>>       * c-c++-common/auto-init-11.c: New test.

>>>       * c-c++-common/auto-init-12.c: New test.

>>>       * c-c++-common/auto-init-13.c: New test.

>>>       * c-c++-common/auto-init-14.c: New test.

>>>       * c-c++-common/auto-init-15.c: New test.

>>>       * c-c++-common/auto-init-16.c: New test.

>>>       * c-c++-common/auto-init-2.c: New test.

>>>       * c-c++-common/auto-init-3.c: New test.

>>>       * c-c++-common/auto-init-4.c: New test.

>>>       * c-c++-common/auto-init-5.c: New test.

>>>       * c-c++-common/auto-init-6.c: New test.

>>>       * c-c++-common/auto-init-7.c: New test.

>>>       * c-c++-common/auto-init-8.c: New test.

>>>       * c-c++-common/auto-init-9.c: New test.

>>>       * c-c++-common/auto-init-esra.c: New test.

>>>       * c-c++-common/auto-init-padding-1.c: New test.

>>>       * c-c++-common/auto-init-padding-2.c: New test.

>>>       * c-c++-common/auto-init-padding-3.c: New test.

> 

> This fails on many targets, e.g. i686-linux or x86_64-linux with -m32.

> 

> The main problem is hardcoding type sizes and structure layout expectations

> that are valid only on some lp64 targets.

> On ilp32 long and pointer are 32-bit, and there are targets that are neither

> ilp32 nor lp64 and there even other sizes can't be taken for granted.

> Also, long double depending on target and options is either 8, 12 or 16 byte

> (the first one when it is the same as double, the second e.g. for ia32

> extended long double (which is under the hood 10 byte), the last either

> the same hw type on x86_64 or IBM double double or IEEE quad).


Is there any testing directive keyword to distinguish this, I see: (https://gcc.gnu.org/onlinedocs/gccint/Effective-Target-Keywords.html)

longdouble128
Target has 128-bit long double.


> In the last test, one problem is that unsigned long is on ilp32 32-bit

> instead of 64-bit, but even just changing to long long is not enough,

> as long long in structures on ia32 is only 4 byte aligned instead of 8.

> 

> Tested on x86_64-linux -m32/-m64, ok for trunk?

> 

> Note, the gcc.dg/i386/auto-init* tests fail also, just don't have time to

> deal with that right now, just try

> make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*'

> Guess some of those tests should be restricted to lp64 in there, others

> where it might be easier to check all of lp64, x32 and ia32 code generation

> could have different matches.

Yes, I am working on this right now, will fix this the beginning of next week.

>  Wonder also about the aarch64 tests, there is

> also -mabi=ilp32...

I expected that aarch64 tests with ilp32 might have similar issue.

> +FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3

> +FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2

> +FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\\t\\\\%xmm0, \\\\%xmm0 3

> +FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

> +FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1

> +FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\\\.long\\t0 14

> +FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2

> +FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1

> +FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 2

> +FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\)\\\\)" 3

> +FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

> +FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2

> +FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 2

> +FAIL: gcc.target/i386/auto-init-padding-1.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-10.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-11.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-12.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-2.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\\t\\\\\$16,

> +FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq

> +FAIL: gcc.target/i386/auto-init-padding-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-5.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\\t\\\\\$0, 2

> +FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\\t\\\\\$0, 2

> +FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq

> 

> 2021-09-11  Jakub Jelinek  <jakub@redhat.com>

> 

> 	* c-c++-common/auto-init-1.c: Enable test only on ilp32 or lp64

> 	targets, expect different long and pointer sizes between ilp32 and

> 	lp64.

> 	* c-c++-common/auto-init-2.c: Likewise.

> 	* c-c++-common/auto-init-3.c: Expect one of the common long double

> 	sizes (8/12/16 bytes) instead of hardcoding 16 bytes.

> 	* c-c++-common/auto-init-4.c: Likewise.

> 	* c-c++-common/auto-init-5.c: Expect one of the common

> 	_Complex long double sizes (16/24/32 bytes) instead of hardcoding 32

> 	bytes.

> 	* c-c++-common/auto-init-6.c: Likewise.

> 	* c-c++-common/auto-init-padding-1.c: Enable test only on ilp32 or lp64

> 	targets.

> 	(struct test_small_hole): Change type of four to unsigned long long

> 	and add aligned attribute.

> 

> --- gcc/testsuite/c-c++-common/auto-init-1.c.jj	2021-09-11 09:33:37.896331809 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-1.c	2021-09-11 09:37:05.108368101 +0200

> @@ -1,5 +1,5 @@

> /* Verify zero initialization for integer and pointer type automatic variables.  */

> -/* { dg-do compile } */

> +/* { dg-do compile { target { ilp32 || lp64 } } } */

> /* { dg-options "-ftrivial-auto-var-init=zero -fdump-tree-gimple" } */

> 

> #ifndef __cplusplus

> @@ -33,7 +33,9 @@ void foo()

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */


Should we add llp64 for “long type” too? I.e.
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target { ilp32 || llp64 } } } } */


From https://gcc.gnu.org/onlinedocs/gccint/Effective-Target-Keywords.html

=========
7.2.3.2 Data type sizes

ilp32
Target has 32-bit int, long, and pointers.

lp64
Target has 32-bit int, 64-bit long and pointers.

llp64
Target has 32-bit int and long, 64-bit long long and pointers.

In the above, looks like that “llp64” also has 32-bit long.


Again, thanks a lot for helping.

Qing

> +/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */

> +/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 2, 0\\)" "gimple" } } */

> --- gcc/testsuite/c-c++-common/auto-init-2.c.jj	2021-09-11 09:33:37.897331795 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-2.c	2021-09-11 09:38:10.908426977 +0200

> @@ -1,5 +1,5 @@

> /* Verify pattern initialization for integer and pointer type automatic variables.  */

> -/* { dg-do compile } */

> +/* { dg-do compile { target { ilp32 || lp64 } } } */

> /* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */

> 

> #ifndef __cplusplus

> @@ -33,7 +33,9 @@ void foo()

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */

> +/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */

> +/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */

> /* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 1, 0\\)" "gimple" } } */

> --- gcc/testsuite/c-c++-common/auto-init-3.c.jj	2021-09-11 09:33:37.897331795 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-3.c	2021-09-11 09:39:40.626143763 +0200

> @@ -16,4 +16,4 @@ long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 2, 0\\)" "gimple" } } */

> --- gcc/testsuite/c-c++-common/auto-init-4.c.jj	2021-09-11 09:33:37.897331795 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-4.c	2021-09-11 09:42:50.645427377 +0200

> @@ -16,4 +16,4 @@ long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 1, 0\\)" "gimple" } } */

> --- gcc/testsuite/c-c++-common/auto-init-5.c.jj	2021-09-11 09:33:37.897331795 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-5.c	2021-09-11 09:43:14.909080575 +0200

> @@ -17,5 +17,5 @@ _Complex long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(32, 2, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 2, 0\\)" "gimple" } } */

> 

> --- gcc/testsuite/c-c++-common/auto-init-6.c.jj	2021-09-11 09:33:37.897331795 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-6.c	2021-09-11 09:43:34.316803177 +0200

> @@ -17,5 +17,5 @@ _Complex long double foo()

> 

> /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */

> /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */

> -/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(32, 1, 0\\)" "gimple" } } */

> +/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 1, 0\\)" "gimple" } } */

> 

> --- gcc/testsuite/c-c++-common/auto-init-padding-1.c.jj	2021-09-11 09:33:37.897331795 +0200

> +++ gcc/testsuite/c-c++-common/auto-init-padding-1.c	2021-09-11 09:48:21.651696258 +0200

> @@ -1,6 +1,6 @@

> /* Verify the padding initialization for pattern initialization, we always emit

>  * a call to __builtin_clear_padding to initialize the paddings to zero.  */

> -/* { dg-do compile } */

> +/* { dg-do compile { target { ilp32 || lp64 } } } */

> /* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */

> 

> 

> @@ -9,7 +9,7 @@ struct test_small_hole {

>   char two;

>   /* 3 byte padding hole here. */

>   int three;

> -  unsigned long four;

> +  unsigned long long four __attribute__((aligned (8)));

> };

> 

> extern void g (struct test_small_hole);

> 

> 

> 	Jakub

>
Antony Polukhin via Gcc-patches Sept. 15, 2021, 5:59 p.m. | #3
> On Sep 11, 2021, at 3:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:

> 

> Note, the gcc.dg/i386/auto-init* tests fail also, just don't have time to

> deal with that right now, just try

> make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*'


It’s strange that the above testing on my local x86 machine with the latest gcc had less failure than the following:

[opc@qinzhao-ol8u3-x86 build-boot]$ make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*' &> log &
[1] 3885164
[opc@qinzhao-ol8u3-x86 build-boot]$ 
[1]+  Done                    make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*' &> log
[opc@qinzhao-ol8u3-x86 build-boot]$ egrep FAIL gcc/testsuite/gcc/gcc.sum
FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2
FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3
FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\t\\%xmm0, \\%xmm0 3
FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1
FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\[0xfefefefefefefefe\\]" 1
FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\]\\) repeated x16" 1
FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\.long\t0 14
FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\t\\$16,
FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq
FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\t\\$0, 2
FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\t\\$0, 2
FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq

I am wondering whether the default value for  “-march” option might be different on different platforms? ( I see if I add -march=cascadelake, then I will get more failures).

I have a patch to the above FAILURES as:

Please take a look and let me know your comments:

thanks.

Qing


From deb44a929ee27b097cc2351c4a4d7644bee68277 Mon Sep 17 00:00:00 2001
From: Qing Zhao <qing.zhao@oracle.com>

Date: Wed, 15 Sep 2021 17:22:07 +0000
Subject: [PATCH] fix i386 testing cases failure for m32

---
 gcc/testsuite/gcc.target/i386/auto-init-2.c         | 6 ++++--
 gcc/testsuite/gcc.target/i386/auto-init-3.c         | 3 ++-
 gcc/testsuite/gcc.target/i386/auto-init-4.c         | 8 +++++---
 gcc/testsuite/gcc.target/i386/auto-init-5.c         | 5 +++--
 gcc/testsuite/gcc.target/i386/auto-init-padding-3.c | 6 ++++--
 gcc/testsuite/gcc.target/i386/auto-init-padding-7.c | 5 +++--
 gcc/testsuite/gcc.target/i386/auto-init-padding-8.c | 7 +++----
 gcc/testsuite/gcc.target/i386/auto-init-padding-9.c | 5 ++++-
 8 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/auto-init-2.c b/gcc/testsuite/gcc.target/i386/auto-init-2.c
index e76fc2565168..ea12b29baefd 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-2.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-2.c
@@ -31,6 +31,8 @@ void foo()
 
 /* { dg-final { scan-rtl-dump-times "0xfffffffffffffffe" 2 "expand" } } */
 /* { dg-final { scan-rtl-dump-times "0xfffffffffffffefe" 1 "expand" } } */
-/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 2 "expand" } } */
-/* { dg-final { scan-rtl-dump-times "0xfefefefefefefefe" 3 "expand" } } */
+/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 2 "expand" { target lp64 } } } */
+/* { dg-final { scan-rtl-dump-times "0xfefefefefefefefe" 3 "expand" { target lp64 } } } */
+/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 4 "expand" { target ia32 } } } */
+/* { dg-final { scan-rtl-dump-times "0xfefefefefefefefe" 1 "expand" { target ia32 } } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-3.c b/gcc/testsuite/gcc.target/i386/auto-init-3.c
index 300ddfb34f11..8c6326384054 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-3.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-3.c
@@ -14,4 +14,5 @@ long double foo()
   return result;
 }
 
-/* { dg-final { scan-assembler-times "pxor\t\\\%xmm0, \\\%xmm0" 3 } } */
+/* { dg-final { scan-assembler-times "pxor\t\\\%xmm0, \\\%xmm0" 3  { target lp64 } } } */
+/* { dg-final { scan-assembler-times "fldz" 3  { target ia32} } } */
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-4.c b/gcc/testsuite/gcc.target/i386/auto-init-4.c
index abe0b7e46a07..62102c7db946 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-4.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-4.c
@@ -14,7 +14,9 @@ long double foo()
   return result;
 }
 
-/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 1 "expand" } } */
-/* { dg-final { scan-rtl-dump-times "\\\[0xfefefefefefefefe\\\]" 1 "expand" } } */
-/* { dg-final { scan-rtl-dump-times "0xfffffffffffffffe\\\]\\\) repeated x16" 1 "expand" } } */
+/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 1 "expand" { target lp64 } } } */
+/* { dg-final { scan-rtl-dump-times "\\\[0xfefefefefefefefe\\\]" 1 "expand" { target lp64 } } } */
+/* { dg-final { scan-rtl-dump-times "0xfffffffffffffffe\\\]\\\) repeated x16" 1 "expand" { target lp64 } } } */
+/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 2 "expand" { target ia32 } } } */
+/* { dg-final { scan-rtl-dump-times "\\\[0xfefefefefefefefe\\\]" 2 "expand" { target ia32 } } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-5.c b/gcc/testsuite/gcc.target/i386/auto-init-5.c
index b2e708c52893..27d971f8cf11 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-5.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-5.c
@@ -1,6 +1,6 @@
 /* Verify zero initialization for complex type automatic variables.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=zero -fdump-rtl-expand" } */
+/* { dg-options "-ftrivial-auto-var-init=zero" } */
 
 
 _Complex long double result;
@@ -15,6 +15,7 @@ _Complex long double foo()
   return result;
 }
 
-/* { dg-final { scan-assembler-times "\\.long\t0" 14 } } */
+/* { dg-final { scan-assembler-times "\\.long\t0" 14 { target lp64 } } } */
+/* { dg-final { scan-assembler-times "\\.long\t0" 12 { target ia32 } } } */
 
 
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-padding-3.c b/gcc/testsuite/gcc.target/i386/auto-init-padding-3.c
index 8a6d764b9fa4..1661c867f915 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-padding-3.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-padding-3.c
@@ -24,7 +24,9 @@ int foo ()
 }
 
 /* { dg-final { scan-assembler "movl\t\\\$0," } } */
-/* { dg-final { scan-assembler "movl\t\\\$16," } } */
-/* { dg-final { scan-assembler "rep stosq" } } */
+/* { dg-final { scan-assembler "movl\t\\\$16," { target lp64 } } } */
+/* { dg-final { scan-assembler "rep stosq" { target lp64 } } } */
+/* { dg-final { scan-assembler "movl\t\\\$32," { target ia32 } } } */
+/* { dg-final { scan-assembler "rep stosl" { target ia32 } } } */
 
 
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-padding-7.c b/gcc/testsuite/gcc.target/i386/auto-init-padding-7.c
index b5abffb0fc66..62c0c042017f 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-padding-7.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-padding-7.c
@@ -1,7 +1,7 @@
 /* Verify zero initialization for structure type automatic variables with
    padding and has explicit initialization.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=zero" } */
+/* { dg-options "-ftrivial-auto-var-init=zero -fdump-rtl-expand" } */
 
 struct test_trailing_hole {
         int one;
@@ -17,6 +17,7 @@ int foo ()
   return var.four;
 }
 
-/* { dg-final { scan-assembler-times "movq\t\\\$0," 2 } } */
+/* { dg-final { scan-rtl-dump-times "const_int 0 \\\[0\\\]\\\) repeated x16" 1 "expand" { target ia32 } } } */
+/* { dg-final { scan-rtl-dump-times "const_int 0 \\\[0\\\]\\\)" 1 "expand" { target lp64 } } } */
 
 
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-padding-8.c b/gcc/testsuite/gcc.target/i386/auto-init-padding-8.c
index 66591cff4488..0e0ee7b8cbbf 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-padding-8.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-padding-8.c
@@ -1,7 +1,7 @@
 /* Verify pattern initialization for structure type automatic variables with
    padding and has explicit initialization.  */
 /* { dg-do compile } */
-/* { dg-options "-ftrivial-auto-var-init=pattern" } */
+/* { dg-options "-ftrivial-auto-var-init=pattern -fdump-rtl-expand" } */
 
 struct test_trailing_hole {
         int one;
@@ -17,6 +17,5 @@ int foo ()
   return var.four;
 }
 
-/* { dg-final { scan-assembler-times "movq\t\\\$0," 2 } } */
-
-
+/* { dg-final { scan-rtl-dump-times "const_int 0 \\\[0\\\]\\\) repeated x16" 1 "expand" { target ia32 } } } */
+/* { dg-final { scan-rtl-dump-times "const_int 0 \\\[0\\\]\\\)" 1 "expand" { target lp64 } } } */
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-padding-9.c b/gcc/testsuite/gcc.target/i386/auto-init-padding-9.c
index 1ff900f95b98..4f02e9566bdc 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-padding-9.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-padding-9.c
@@ -19,4 +19,7 @@ int foo ()
 }
 
 /* { dg-final { scan-assembler "movl\t\\\$0," } } */
-/* { dg-final { scan-assembler "rep stosq" } } */
+/* { dg-final { scan-assembler "movl\t\\\$20," { target lp64} } } */
+/* { dg-final { scan-assembler "rep stosq" { target lp64 } } } */
+/* { dg-final { scan-assembler "movl\t\\\$40," { target ia32} } } */
+/* { dg-final { scan-assembler "rep stosl" { target ia32 } } } */
-- 
2.27.0



> Guess some of those tests should be restricted to lp64 in there, others

> where it might be easier to check all of lp64, x32 and ia32 code generation

> could have different matches.  Wonder also about the aarch64 tests, there is

> also -mabi=ilp32...

> +FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3

> +FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2

> +FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\\t\\\\%xmm0, \\\\%xmm0 3

> +FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

> +FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1

> +FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\\\.long\\t0 14

> +FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2

> +FAIL: gcc.target/i386/auto-init-6.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 1

> +FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 2

> +FAIL: gcc.target/i386/auto-init-7.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\)\\\\)" 3

> +FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

> +FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 2

> +FAIL: gcc.target/i386/auto-init-8.c scan-rtl-dump-times expand "\\\\[0xfefefefefefefefe\\\\]" 2

> +FAIL: gcc.target/i386/auto-init-padding-1.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-10.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-11.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-12.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-2.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\\t\\\\\$16,

> +FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq

> +FAIL: gcc.target/i386/auto-init-padding-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-5.c scan-rtl-dump-times expand "const_int 0 \\\\[0\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-6.c scan-rtl-dump-times expand "0xfffffffffffffffe\\\\]\\\\) repeated x16" 1

> +FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\\t\\\\\$0, 2

> +FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\\t\\\\\$0, 2

> +FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq

>
Antony Polukhin via Gcc-patches Sept. 16, 2021, 9:19 a.m. | #4
On Wed, Sep 15, 2021 at 05:59:08PM +0000, Qing Zhao wrote:
> > Note, the gcc.dg/i386/auto-init* tests fail also, just don't have time to

> > deal with that right now, just try

> > make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*'

> 

> It’s strange that the above testing on my local x86 machine with the latest gcc had less failure than the following:

> 

> [opc@qinzhao-ol8u3-x86 build-boot]$ make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*' &> log &

> [1] 3885164

> [opc@qinzhao-ol8u3-x86 build-boot]$ 

> [1]+  Done                    make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*' &> log

> [opc@qinzhao-ol8u3-x86 build-boot]$ egrep FAIL gcc/testsuite/gcc/gcc.sum

> FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2

> FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3

> FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\t\\%xmm0, \\%xmm0 3

> FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

> FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\[0xfefefefefefefefe\\]" 1

> FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\]\\) repeated x16" 1

> FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\.long\t0 14

> FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\t\\$16,

> FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq

> FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\t\\$0, 2

> FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\t\\$0, 2

> FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq


Testing for many instructions is always very fragile and dependent on exact
compiler flags etc.  So, either the test should have a particular
-march=/-mtune= options and ideally also -fno-stack-protector
-fno-stack-clash-protection etc. if they could change the expected matching,
or test it at runtime instead (I know, it is playing with fire, because you
are testing the behavior of UB, but perhaps making the functions that use
the uninitialized vars __attribute__((noipa)) and checking whether the vars
contain the expected values might be ok.

	Jakub
Antony Polukhin via Gcc-patches Sept. 16, 2021, 2:49 p.m. | #5
Hi, Jakub,

> On Sep 16, 2021, at 4:19 AM, Jakub Jelinek <jakub@redhat.com> wrote:

> 

> On Wed, Sep 15, 2021 at 05:59:08PM +0000, Qing Zhao wrote:

>>> Note, the gcc.dg/i386/auto-init* tests fail also, just don't have time to

>>> deal with that right now, just try

>>> make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*'

>> 

>> It’s strange that the above testing on my local x86 machine with the latest gcc had less failure than the following:

>> 

>> [opc@qinzhao-ol8u3-x86 build-boot]$ make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*' &> log &

>> [1] 3885164

>> [opc@qinzhao-ol8u3-x86 build-boot]$ 

>> [1]+  Done                    make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=auto-init*' &> log

>> [opc@qinzhao-ol8u3-x86 build-boot]$ egrep FAIL gcc/testsuite/gcc/gcc.sum

>> FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfffffffffefefefe" 2

>> FAIL: gcc.target/i386/auto-init-2.c scan-rtl-dump-times expand "0xfefefefefefefefe" 3

>> FAIL: gcc.target/i386/auto-init-3.c scan-assembler-times pxor\t\\%xmm0, \\%xmm0 3

>> FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffefefefe" 1

>> FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "\\[0xfefefefefefefefe\\]" 1

>> FAIL: gcc.target/i386/auto-init-4.c scan-rtl-dump-times expand "0xfffffffffffffffe\\]\\) repeated x16" 1

>> FAIL: gcc.target/i386/auto-init-5.c scan-assembler-times \\.long\t0 14

>> FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler movl\t\\$16,

>> FAIL: gcc.target/i386/auto-init-padding-3.c scan-assembler rep stosq

>> FAIL: gcc.target/i386/auto-init-padding-7.c scan-assembler-times movq\t\\$0, 2

>> FAIL: gcc.target/i386/auto-init-padding-8.c scan-assembler-times movq\t\\$0, 2

>> FAIL: gcc.target/i386/auto-init-padding-9.c scan-assembler rep stosq

> 

> Testing for many instructions is always very fragile and dependent on exact

> compiler flags etc.


Yes, It’s indeed very fragile. 
>  So, either the test should have a particular

> -march=/-mtune= options


I might add specific -march to the testing cases. 

> and ideally also -fno-stack-protector

> -fno-stack-clash-protection etc.


Could you explain a little bit on this why?

> if they could change the expected matching,

> or test it at runtime instead(I know, it is playing with fire, because you

> are testing the behavior of UB, but perhaps making the functions that use

> the uninitialized vars __attribute__((noipa)) and checking whether the vars

> contain the expected values might be ok.


I thought of doing the testing at runtime too in the beginning, however, I was worried about how can we be sure that the correct values  in the variable come from the compiler initialization? 
I will try one more time to see whether I can come up with a runtime testing case.

Thanks a lot.

Qing
> 

> 	Jakub

>
Antony Polukhin via Gcc-patches Sept. 16, 2021, 2:56 p.m. | #6
On Thu, Sep 16, 2021 at 02:49:23PM +0000, Qing Zhao wrote:
> > Testing for many instructions is always very fragile and dependent on exact

> > compiler flags etc.

> 

> Yes, It’s indeed very fragile. 

> >  So, either the test should have a particular

> > -march=/-mtune= options

> 

> I might add specific -march to the testing cases. 


Even -mtune= is needed if you want to stay safe, otherwise people testing
with --target_board=unix/-mtune=cascadelake (or whatever else) might get
failures.

> > and ideally also -fno-stack-protector

> > -fno-stack-clash-protection etc.

> 

> Could you explain a little bit on this why?


In case people test e.g. with --target_board=unix/\{,-fstack-protector-all\}
etc. (e.g. in Fedora/RHEL we do).
For the RTL scanning checks if they are done fairly early, those options
might not change anything, but with the ones scanning in the assembly,
one needs to watch if those options don't add e.g. in the prologue or
epilogue further copies of the instructions you scan for.

	Jakub
Antony Polukhin via Gcc-patches Sept. 16, 2021, 3:39 p.m. | #7
> On Sep 16, 2021, at 9:56 AM, Jakub Jelinek <jakub@redhat.com> wrote:

> 

> On Thu, Sep 16, 2021 at 02:49:23PM +0000, Qing Zhao wrote:

>>> Testing for many instructions is always very fragile and dependent on exact

>>> compiler flags etc.

>> 

>> Yes, It’s indeed very fragile. 

>>> So, either the test should have a particular

>>> -march=/-mtune= options

>> 

>> I might add specific -march to the testing cases. 

> 

> Even -mtune= is needed if you want to stay safe, otherwise people testing

> with --target_board=unix/-mtune=cascadelake (or whatever else) might get

> failures.


Okay. Will try this.
> 

>>> and ideally also -fno-stack-protector

>>> -fno-stack-clash-protection etc.

>> 

>> Could you explain a little bit on this why?

> 

> In case people test e.g. with --target_board=unix/\{,-fstack-protector-all\}

> etc. (e.g. in Fedora/RHEL we do).

> For the RTL scanning checks if they are done fairly early, those options

> might not change anything, but with the ones scanning in the assembly,

> one needs to watch if those options don't add e.g. in the prologue or

> epilogue further copies of the instructions you scan for.


I see. 

Thank you.

Qing
> 

> 	Jakub

>
Antony Polukhin via Gcc-patches Sept. 16, 2021, 3:47 p.m. | #8
On Thu, Sep 16, 2021 at 03:39:46PM +0000, Qing Zhao wrote:
> > Even -mtune= is needed if you want to stay safe, otherwise people testing

> > with --target_board=unix/-mtune=cascadelake (or whatever else) might get

> > failures.

> 

> Okay. Will try this.

> > 

> >>> and ideally also -fno-stack-protector

> >>> -fno-stack-clash-protection etc.

> >> 

> >> Could you explain a little bit on this why?

> > 

> > In case people test e.g. with --target_board=unix/\{,-fstack-protector-all\}

> > etc. (e.g. in Fedora/RHEL we do).

> > For the RTL scanning checks if they are done fairly early, those options

> > might not change anything, but with the ones scanning in the assembly,

> > one needs to watch if those options don't add e.g. in the prologue or

> > epilogue further copies of the instructions you scan for.

> 

> I see. 

> 

> Thank you.


Basically, try to test with a bunch of semi-randomly chosen option sets and
see what breaks and what works and then for the cases you think are common
enough and worth adjusting testcases adjust them, otherwise add dg-options
to make sure the expected arch/tune/etc. are in effect.
make check-gcc RUNTESTFLAGS='--target_board=unix\{-m64,-m64/-march=skylake-avx512,-m64/-fstack-protector-all,-m64/-fstack-clash-protection,-m32/-mno-sse,-m32/-mtune=bonnell,-m32/-march=bonnell,-m32/-fstack-protector-all/-fstack-clash-protection\} i386.exp=auto-init*'
etc.

	Jakub
Antony Polukhin via Gcc-patches Sept. 16, 2021, 5:11 p.m. | #9
> On Sep 16, 2021, at 10:47 AM, Jakub Jelinek <jakub@redhat.com> wrote:

> 

> On Thu, Sep 16, 2021 at 03:39:46PM +0000, Qing Zhao wrote:

>>> Even -mtune= is needed if you want to stay safe, otherwise people testing

>>> with --target_board=unix/-mtune=cascadelake (or whatever else) might get

>>> failures.

>> 

>> Okay. Will try this.

>>> 

>>>>> and ideally also -fno-stack-protector

>>>>> -fno-stack-clash-protection etc.

>>>> 

>>>> Could you explain a little bit on this why?

>>> 

>>> In case people test e.g. with --target_board=unix/\{,-fstack-protector-all\}

>>> etc. (e.g. in Fedora/RHEL we do).

>>> For the RTL scanning checks if they are done fairly early, those options

>>> might not change anything, but with the ones scanning in the assembly,

>>> one needs to watch if those options don't add e.g. in the prologue or

>>> epilogue further copies of the instructions you scan for.

>> 

>> I see. 

>> 

>> Thank you.

> 

> Basically, try to test with a bunch of semi-randomly chosen option sets and

> see what breaks and what works and then for the cases you think are common

> enough and worth adjusting testcases adjust them, otherwise add dg-options

> to make sure the expected arch/tune/etc. are in effect.

> make check-gcc RUNTESTFLAGS='--target_board=unix\{-m64,-m64/-march=skylake-avx512,-m64/-fstack-protector-all,-m64/-fstack-clash-protection,-m32/-mno-sse,-m32/-mtune=bonnell,-m32/-march=bonnell,-m32/-fstack-protector-all/-fstack-clash-protection\} i386.exp=auto-init*'


Thanks a lot for the suggestions and help, I will try this.

Qing
> etc.

> 

> 	Jakub

>
Antony Polukhin via Gcc-patches Sept. 16, 2021, 5:39 p.m. | #10
> On 16 Sep 2021, at 18:11, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

> 

> 

> 

>> On Sep 16, 2021, at 10:47 AM, Jakub Jelinek <jakub@redhat.com> wrote:

>> 

>> On Thu, Sep 16, 2021 at 03:39:46PM +0000, Qing Zhao wrote:

>>>> Even -mtune= is needed if you want to stay safe, otherwise people testing

>>>> with --target_board=unix/-mtune=cascadelake (or whatever else) might get

>>>> failures.

>>> 

>>> Okay. Will try this.

>>>> 

>>>>>> and ideally also -fno-stack-protector

>>>>>> -fno-stack-clash-protection etc.

>>>>> 

>>>>> Could you explain a little bit on this why?

>>>> 

>>>> In case people test e.g. with --target_board=unix/\{,-fstack-protector-all\}

>>>> etc. (e.g. in Fedora/RHEL we do).

>>>> For the RTL scanning checks if they are done fairly early, those options

>>>> might not change anything, but with the ones scanning in the assembly,

>>>> one needs to watch if those options don't add e.g. in the prologue or

>>>> epilogue further copies of the instructions you scan for.

>>> 

>>> I see. 

>>> 

>>> Thank you.

>> 

>> Basically, try to test with a bunch of semi-randomly chosen option sets and

>> see what breaks and what works and then for the cases you think are common

>> enough and worth adjusting testcases adjust them, otherwise add dg-options

>> to make sure the expected arch/tune/etc. are in effect.

>> make check-gcc RUNTESTFLAGS='--target_board=unix\{-m64,-m64/-march=skylake-avx512,-m64/-fstack-protector-all,-m64/-fstack-clash-protection,-m32/-mno-sse,-m32/-mtune=bonnell,-m32/-march=bonnell,-m32/-fstack-protector-all/-fstack-clash-protection\} i386.exp=auto-init*'

> 

> Thanks a lot for the suggestions and help, I will try this.


I might suggest adding -fPIC or -fpic to the mix too (if it’s relevant to the tests) there are quite a few testcases that fail when run on Darwin (or HJ’s pic tester versions) because of the difference in code-gen.
Iain

> 

> Qing

>> etc.

>> 

>> 	Jakub
Antony Polukhin via Gcc-patches Sept. 16, 2021, 6:55 p.m. | #11
> On Sep 16, 2021, at 12:39 PM, Iain Sandoe <idsandoe@googlemail.com> wrote:

> 

> 

> 

>> On 16 Sep 2021, at 18:11, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

>> 

>> 

>> 

>>> On Sep 16, 2021, at 10:47 AM, Jakub Jelinek <jakub@redhat.com> wrote:

>>> 

>>> On Thu, Sep 16, 2021 at 03:39:46PM +0000, Qing Zhao wrote:

>>>>> Even -mtune= is needed if you want to stay safe, otherwise people testing

>>>>> with --target_board=unix/-mtune=cascadelake (or whatever else) might get

>>>>> failures.

>>>> 

>>>> Okay. Will try this.

>>>>> 

>>>>>>> and ideally also -fno-stack-protector

>>>>>>> -fno-stack-clash-protection etc.

>>>>>> 

>>>>>> Could you explain a little bit on this why?

>>>>> 

>>>>> In case people test e.g. with --target_board=unix/\{,-fstack-protector-all\}

>>>>> etc. (e.g. in Fedora/RHEL we do).

>>>>> For the RTL scanning checks if they are done fairly early, those options

>>>>> might not change anything, but with the ones scanning in the assembly,

>>>>> one needs to watch if those options don't add e.g. in the prologue or

>>>>> epilogue further copies of the instructions you scan for.

>>>> 

>>>> I see. 

>>>> 

>>>> Thank you.

>>> 

>>> Basically, try to test with a bunch of semi-randomly chosen option sets and

>>> see what breaks and what works and then for the cases you think are common

>>> enough and worth adjusting testcases adjust them, otherwise add dg-options

>>> to make sure the expected arch/tune/etc. are in effect.

>>> make check-gcc RUNTESTFLAGS='--target_board=unix\{-m64,-m64/-march=skylake-avx512,-m64/-fstack-protector-all,-m64/-fstack-clash-protection,-m32/-mno-sse,-m32/-mtune=bonnell,-m32/-march=bonnell,-m32/-fstack-protector-all/-fstack-clash-protection\} i386.exp=auto-init*'

>> 

>> Thanks a lot for the suggestions and help, I will try this.

> 

> I might suggest adding -fPIC or -fpic to the mix too (if it’s relevant to the tests) there are quite a few testcases that fail when run on Darwin (or HJ’s pic tester versions) because of the difference in code-gen.


Okay, will add that. Thanks.

Qing
> Iain

> 

>> 

>> Qing

>>> etc.

>>> 

>>> 	Jakub

Patch

--- gcc/testsuite/c-c++-common/auto-init-1.c.jj	2021-09-11 09:33:37.896331809 +0200
+++ gcc/testsuite/c-c++-common/auto-init-1.c	2021-09-11 09:37:05.108368101 +0200
@@ -1,5 +1,5 @@ 
 /* Verify zero initialization for integer and pointer type automatic variables.  */
-/* { dg-do compile } */
+/* { dg-do compile { target { ilp32 || lp64 } } } */
 /* { dg-options "-ftrivial-auto-var-init=zero -fdump-tree-gimple" } */
 
 #ifndef __cplusplus
@@ -33,7 +33,9 @@  void foo()
 /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 2, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */
 /* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */
 /* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 2, 0\\)" "gimple" } } */
--- gcc/testsuite/c-c++-common/auto-init-2.c.jj	2021-09-11 09:33:37.897331795 +0200
+++ gcc/testsuite/c-c++-common/auto-init-2.c	2021-09-11 09:38:10.908426977 +0200
@@ -1,5 +1,5 @@ 
 /* Verify pattern initialization for integer and pointer type automatic variables.  */
-/* { dg-do compile } */
+/* { dg-do compile { target { ilp32 || lp64 } } } */
 /* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */
 
 #ifndef __cplusplus
@@ -33,7 +33,9 @@  void foo()
 /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 1, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */
 /* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */
 /* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 1, 0\\)" "gimple" } } */
--- gcc/testsuite/c-c++-common/auto-init-3.c.jj	2021-09-11 09:33:37.897331795 +0200
+++ gcc/testsuite/c-c++-common/auto-init-3.c	2021-09-11 09:39:40.626143763 +0200
@@ -16,4 +16,4 @@  long double foo()
 
 /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 2, 0\\)" "gimple" } } */
--- gcc/testsuite/c-c++-common/auto-init-4.c.jj	2021-09-11 09:33:37.897331795 +0200
+++ gcc/testsuite/c-c++-common/auto-init-4.c	2021-09-11 09:42:50.645427377 +0200
@@ -16,4 +16,4 @@  long double foo()
 
 /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 1, 0\\)" "gimple" } } */
--- gcc/testsuite/c-c++-common/auto-init-5.c.jj	2021-09-11 09:33:37.897331795 +0200
+++ gcc/testsuite/c-c++-common/auto-init-5.c	2021-09-11 09:43:14.909080575 +0200
@@ -17,5 +17,5 @@  _Complex long double foo()
 
 /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(32, 2, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 2, 0\\)" "gimple" } } */
 
--- gcc/testsuite/c-c++-common/auto-init-6.c.jj	2021-09-11 09:33:37.897331795 +0200
+++ gcc/testsuite/c-c++-common/auto-init-6.c	2021-09-11 09:43:34.316803177 +0200
@@ -17,5 +17,5 @@  _Complex long double foo()
 
 /* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
 /* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(32, 1, 0\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 1, 0\\)" "gimple" } } */
 
--- gcc/testsuite/c-c++-common/auto-init-padding-1.c.jj	2021-09-11 09:33:37.897331795 +0200
+++ gcc/testsuite/c-c++-common/auto-init-padding-1.c	2021-09-11 09:48:21.651696258 +0200
@@ -1,6 +1,6 @@ 
 /* Verify the padding initialization for pattern initialization, we always emit
  * a call to __builtin_clear_padding to initialize the paddings to zero.  */
-/* { dg-do compile } */
+/* { dg-do compile { target { ilp32 || lp64 } } } */
 /* { dg-options "-ftrivial-auto-var-init=pattern -fdump-tree-gimple" } */
 
 
@@ -9,7 +9,7 @@  struct test_small_hole {
   char two;
   /* 3 byte padding hole here. */
   int three;
-  unsigned long four;
+  unsigned long long four __attribute__((aligned (8)));
 };
 
 extern void g (struct test_small_hole);