diff mbox

Fix gcc.dg/tree-ssa/scev-[345].c testcases

Message ID alpine.LSU.2.20.1701131042230.14052@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Jan. 13, 2017, 9:46 a.m. UTC
The following is an attempt to change those testcases to be less dependent
on previous passes.  The original motivation of the testcases seems to be
testing SCEV capabilities and in turn IVOPTs decisions, thus the testcases
are changed to check the IVO dump, use the GIMPLE FE feeding the loop
pipeline directly and skip lowering/store-motion we meanwhile do to
the testcase.

To avoid some existing issue with CFG construction after GIMPLE parsing
we need to be able to add GIMPLE_NOPs which the patch enables to generate
from empty stmts (previously those resulted in parse errors).

Tested the testcases on x86_64 with {,-m32} sofar I'll appreciate
testing on more targets.

Full bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2017-01-13  Richard Biener  <rguenther@suse.de>

	PR testsuite/52563
	PR testsuite/71237
	PR testsuite/77737
	c/
	* gimple-parser.c (c_parser_gimple_compound_statement): Handle
	nops.

	* gcc.dg/tree-ssa/scev-3.c: Re-write to a GIMPLE testcase for IVOPTs.
	* gcc.dg/tree-ssa/scev-4.c: Likewise.
	* gcc.dg/tree-ssa/scev-5.c: Likewise.

Comments

Bin.Cheng Jan. 13, 2017, 11:16 a.m. UTC | #1
On Fri, Jan 13, 2017 at 9:46 AM, Richard Biener <rguenther@suse.de> wrote:
>
> The following is an attempt to change those testcases to be less dependent
> on previous passes.  The original motivation of the testcases seems to be
> testing SCEV capabilities and in turn IVOPTs decisions, thus the testcases
> are changed to check the IVO dump, use the GIMPLE FE feeding the loop
> pipeline directly and skip lowering/store-motion we meanwhile do to
> the testcase.
>
> To avoid some existing issue with CFG construction after GIMPLE parsing
> we need to be able to add GIMPLE_NOPs which the patch enables to generate
> from empty stmts (previously those resulted in parse errors).
>
> Tested the testcases on x86_64 with {,-m32} sofar I'll appreciate
> testing on more targets.
I checked aarch64-elf/aarch64-linux with default configuration, all
passed with this change.

Thanks,
bin
>
> Full bootstrap / regtest running on x86_64-unknown-linux-gnu.
>
> Richard.
>

> -        }
>  }
>
> -/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
> +/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */
Christophe Lyon Jan. 16, 2017, 9:39 a.m. UTC | #2
On 13 January 2017 at 12:16, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Fri, Jan 13, 2017 at 9:46 AM, Richard Biener <rguenther@suse.de> wrote:
>>
>> The following is an attempt to change those testcases to be less dependent
>> on previous passes.  The original motivation of the testcases seems to be
>> testing SCEV capabilities and in turn IVOPTs decisions, thus the testcases
>> are changed to check the IVO dump, use the GIMPLE FE feeding the loop
>> pipeline directly and skip lowering/store-motion we meanwhile do to
>> the testcase.
>>
>> To avoid some existing issue with CFG construction after GIMPLE parsing
>> we need to be able to add GIMPLE_NOPs which the patch enables to generate
>> from empty stmts (previously those resulted in parse errors).
>>
>> Tested the testcases on x86_64 with {,-m32} sofar I'll appreciate
>> testing on more targets.
> I checked aarch64-elf/aarch64-linux with default configuration, all
> passed with this change.
>

For me, the testcases don't compile with this patch:
gcc.dg/tree-ssa/scev-3.c: In function 'f':
gcc.dg/tree-ssa/scev-3.c:30:3: error: '__MEM' undeclared (first use in
this function)
gcc.dg/tree-ssa/scev-3.c:30:3: note: each undeclared identifier is
reported only once for each function it appears in
gcc.dg/tree-ssa/scev-3.c:30:9: error: expected '=' before '<' token

Did I misapply the patch?

> Thanks,
> bin
>>
>> Full bootstrap / regtest running on x86_64-unknown-linux-gnu.
>>
>> Richard.
>>
>
>> -        }
>>  }
>>
>> -/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
>> +/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */
Richard Biener Jan. 16, 2017, 9:43 a.m. UTC | #3
On Mon, 16 Jan 2017, Christophe Lyon wrote:

> On 13 January 2017 at 12:16, Bin.Cheng <amker.cheng@gmail.com> wrote:
> > On Fri, Jan 13, 2017 at 9:46 AM, Richard Biener <rguenther@suse.de> wrote:
> >>
> >> The following is an attempt to change those testcases to be less dependent
> >> on previous passes.  The original motivation of the testcases seems to be
> >> testing SCEV capabilities and in turn IVOPTs decisions, thus the testcases
> >> are changed to check the IVO dump, use the GIMPLE FE feeding the loop
> >> pipeline directly and skip lowering/store-motion we meanwhile do to
> >> the testcase.
> >>
> >> To avoid some existing issue with CFG construction after GIMPLE parsing
> >> we need to be able to add GIMPLE_NOPs which the patch enables to generate
> >> from empty stmts (previously those resulted in parse errors).
> >>
> >> Tested the testcases on x86_64 with {,-m32} sofar I'll appreciate
> >> testing on more targets.
> > I checked aarch64-elf/aarch64-linux with default configuration, all
> > passed with this change.
> >
> 
> For me, the testcases don't compile with this patch:
> gcc.dg/tree-ssa/scev-3.c: In function 'f':
> gcc.dg/tree-ssa/scev-3.c:30:3: error: '__MEM' undeclared (first use in
> this function)
> gcc.dg/tree-ssa/scev-3.c:30:3: note: each undeclared identifier is
> reported only once for each function it appears in
> gcc.dg/tree-ssa/scev-3.c:30:9: error: expected '=' before '<' token
> 
> Did I misapply the patch?

You need

2017-01-12  Richard Biener  <rguenther@suse.de>

        * gimple-parser.c (c_parser_gimple_postfix_expression): Parse
        __MEM.

in c/ChangeLog for it to work.

Richard.

> > Thanks,
> > bin
> >>
> >> Full bootstrap / regtest running on x86_64-unknown-linux-gnu.
> >>
> >> Richard.
> >>
> >
> >> -        }
> >>  }
> >>
> >> -/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
> >> +/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */
> 
>
Rainer Orth Jan. 16, 2017, 9:51 a.m. UTC | #4
Hi Richard,

> The following is an attempt to change those testcases to be less dependent
> on previous passes.  The original motivation of the testcases seems to be
> testing SCEV capabilities and in turn IVOPTs decisions, thus the testcases
> are changed to check the IVO dump, use the GIMPLE FE feeding the loop
> pipeline directly and skip lowering/store-motion we meanwhile do to
> the testcase.
>
> To avoid some existing issue with CFG construction after GIMPLE parsing
> we need to be able to add GIMPLE_NOPs which the patch enables to generate
> from empty stmts (previously those resulted in parse errors).
>
> Tested the testcases on x86_64 with {,-m32} sofar I'll appreciate
> testing on more targets.

I had included the patch in this weekend's Solaris bootstraps and all
scev-?.c failures were gone on both sparc and x86.

Thanks.
        Rainer
Christophe Lyon Jan. 16, 2017, 4:02 p.m. UTC | #5
On 16 January 2017 at 10:43, Richard Biener <rguenther@suse.de> wrote:
> On Mon, 16 Jan 2017, Christophe Lyon wrote:
>
>> On 13 January 2017 at 12:16, Bin.Cheng <amker.cheng@gmail.com> wrote:
>> > On Fri, Jan 13, 2017 at 9:46 AM, Richard Biener <rguenther@suse.de> wrote:
>> >>
>> >> The following is an attempt to change those testcases to be less dependent
>> >> on previous passes.  The original motivation of the testcases seems to be
>> >> testing SCEV capabilities and in turn IVOPTs decisions, thus the testcases
>> >> are changed to check the IVO dump, use the GIMPLE FE feeding the loop
>> >> pipeline directly and skip lowering/store-motion we meanwhile do to
>> >> the testcase.
>> >>
>> >> To avoid some existing issue with CFG construction after GIMPLE parsing
>> >> we need to be able to add GIMPLE_NOPs which the patch enables to generate
>> >> from empty stmts (previously those resulted in parse errors).
>> >>
>> >> Tested the testcases on x86_64 with {,-m32} sofar I'll appreciate
>> >> testing on more targets.
>> > I checked aarch64-elf/aarch64-linux with default configuration, all
>> > passed with this change.
>> >
>>
>> For me, the testcases don't compile with this patch:
>> gcc.dg/tree-ssa/scev-3.c: In function 'f':
>> gcc.dg/tree-ssa/scev-3.c:30:3: error: '__MEM' undeclared (first use in
>> this function)
>> gcc.dg/tree-ssa/scev-3.c:30:3: note: each undeclared identifier is
>> reported only once for each function it appears in
>> gcc.dg/tree-ssa/scev-3.c:30:9: error: expected '=' before '<' token
>>
>> Did I misapply the patch?
>
> You need
>
> 2017-01-12  Richard Biener  <rguenther@suse.de>
>
>         * gimple-parser.c (c_parser_gimple_postfix_expression): Parse
>         __MEM.
>
> in c/ChangeLog for it to work.
>

Indeed, thanks.
With it, I confirm the tests now pass on aarch64 and arm.
Thanks

Christophe

> Richard.
>
>> > Thanks,
>> > bin
>> >>
>> >> Full bootstrap / regtest running on x86_64-unknown-linux-gnu.
>> >>
>> >> Richard.
>> >>
>> >
>> >> -        }
>> >>  }
>> >>
>> >> -/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
>> >> +/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */
>>
>>
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
diff mbox

Patch

Index: gcc/c/gimple-parser.c
===================================================================
--- gcc/c/gimple-parser.c	(revision 244393)
+++ gcc/c/gimple-parser.c	(working copy)
@@ -211,6 +211,17 @@  c_parser_gimple_compound_statement (c_pa
 	    }
 	  goto expr_stmt;
 
+	case CPP_SEMICOLON:
+	  {
+	    /* Empty stmt.  */
+	    location_t loc = c_parser_peek_token (parser)->location;
+	    c_parser_consume_token (parser);
+	    gimple *nop = gimple_build_nop ();
+	    gimple_set_location (nop, loc);
+	    gimple_seq_add_stmt (seq, nop);
+	    break;
+	  }
+
 	default:
 expr_stmt:
 	  c_parser_gimple_statement (parser, seq);
Index: gcc/testsuite/gcc.dg/tree-ssa/scev-3.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/scev-3.c	(revision 244393)
+++ gcc/testsuite/gcc.dg/tree-ssa/scev-3.c	(working copy)
@@ -1,18 +1,43 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fgimple -fdump-tree-ivopts" } */
 
 int *a_p;
 int a[1000];
 
-void
-f(int k)
+void __GIMPLE (startwith ("loop"))
+f (int k)
 {
-	int i;
+  int i;
+  int * _1;
+
+bb_2:
+  i_5 = k_4(D);
+  if (i_5 <= 999)
+    goto bb_4;
+  else
+    goto bb_3;
+
+bb_3:
+  return;
+
+bb_4:
+  ;
+
+bb_5:
+  i_12 = __PHI (bb_6: i_9, bb_4: i_5);
+  _1 = &a[i_12];
+  a_p = _1;
+  __MEM <int[1000]> ((int *)&a)[i_12] = 100;
+  i_9 = i_5 + i_12;
+  if (i_9 <= 999)
+    goto bb_6;
+  else
+    goto bb_3;
+
+bb_6:
+  ;
+  goto bb_5;
 
-	for (i=k; i<1000; i+=k) {
-		a_p = &a[i];
-		*a_p = 100;
-        }
 }
 
-/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */
Index: gcc/testsuite/gcc.dg/tree-ssa/scev-4.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/scev-4.c	(revision 244393)
+++ gcc/testsuite/gcc.dg/tree-ssa/scev-4.c	(working copy)
@@ -1,23 +1,48 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fgimple -fdump-tree-ivopts" } */
 
 typedef struct {
-	int x;
-	int y;
+    int x;
+    int y;
 } S;
 
 int *a_p;
 S a[1000];
 
-void
-f(int k)
+void __GIMPLE (startwith ("loop"))
+f (int k)
 {
-	int i;
+  int i;
+  int * _1;
+
+bb_2:
+  i_5 = k_4(D);
+  if (i_5 <= 999)
+    goto bb_4;
+  else
+    goto bb_3;
+
+bb_3:
+  return;
+
+bb_4:
+  ;
+
+bb_5:
+  i_12 = __PHI (bb_6: i_9, bb_4: i_5);
+  _1 = &a[i_12].y;
+  a_p = _1;
+  __MEM <S[1000]> ((int *)&a)[i_12].y = 100;
+  i_9 = i_5 + i_12;
+  if (i_9 <= 999)
+    goto bb_6;
+  else
+    goto bb_3;
+
+bb_6:
+  ;
+  goto bb_5;
 
-	for (i=k; i<1000; i+=k) {
-		a_p = &a[i].y;
-		*a_p = 100;
-        }
 }
 
-/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */
Index: gcc/testsuite/gcc.dg/tree-ssa/scev-5.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/scev-5.c	(revision 244393)
+++ gcc/testsuite/gcc.dg/tree-ssa/scev-5.c	(working copy)
@@ -1,18 +1,43 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fgimple -fdump-tree-ivopts" } */
 
 int *a_p;
 int a[1000];
 
-void
-f(int k)
+void __GIMPLE (startwith ("loop"))
+f (int k)
 {
-        long long i;
+  long long int i;
+  int * _1;
+
+bb_2:
+  i_5 = (long long int) k_4(D);
+  if (i_5 <= 999ll)
+    goto bb_4;
+  else
+    goto bb_3;
+
+bb_3:
+  return;
+
+bb_4:
+  ;
+
+bb_5:
+  i_12 = __PHI (bb_6: i_9, bb_4: i_5);
+  _1 = &a[i_12];
+  a_p = _1;
+  __MEM <int[1000]> ((int *)&a)[i_12] = 100;
+  i_9 = i_5 + i_12;
+  if (i_9 <= 999ll)
+    goto bb_6;
+  else
+    goto bb_3;
+
+bb_6:
+  ;
+  goto bb_5;
 
-        for (i=k; i<1000; i+=k) {
-                a_p = &a[i];
-                *a_p = 100;
-        }
 }
 
-/* { dg-final { scan-tree-dump-times "&a" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "&a" 1 "ivopts" } } */