public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Add DSE to early passes
@ 2015-04-13 10:01 Jan Hubicka
  2015-04-13 12:12 ` Richard Biener
  2015-04-22 12:13 ` H.J. Lu
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Hubicka @ 2015-04-13 10:01 UTC (permalink / raw)
  To: rguenther, gcc-patches

Hi,
this patch adds DSE to early optimizations and handles testuiste fallout.
As discussed in PR 65076 this reduces number of CLOBBER statements in tramp3d
to 50% (and those accounts 29% of all code previously). The pass also quite
often kills real stores reducing Firefox binary by over 2% due to
better inline decisions.

Bootstrapped/regtested ppc64-linux, OK?

Honza

	* passes.def (early_optimizations): Add pass_dse.

	* g++.dg/tree-ssa/pr61034.C: Update template.
	* g++.dg/warn/Warray-bounds.C: Harden for DSE.
	* gcc.dg/Warray-bounds-11.c: Likewise.
	* gcc.dg/Warray-bounds.c: Likewise.
Index: passes.def
===================================================================
--- passes.def	(revision 222016)
+++ passes.def	(working copy)
@@ -89,6 +89,7 @@ along with GCC; see the file COPYING3.
 	  NEXT_PASS (pass_build_ealias);
 	  NEXT_PASS (pass_fre);
 	  NEXT_PASS (pass_merge_phi);
+          NEXT_PASS (pass_dse);
 	  NEXT_PASS (pass_cd_dce);
 	  NEXT_PASS (pass_early_ipa_sra);
 	  NEXT_PASS (pass_tail_recursion);
Index: testsuite/g++.dg/tree-ssa/pr61034.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr61034.C	(revision 222016)
+++ testsuite/g++.dg/tree-ssa/pr61034.C	(working copy)
@@ -42,6 +42,6 @@ bool f(I a, I b, I c, I d) {
 // This works only if everything is inlined into 'f'.
 
 // { dg-final { scan-tree-dump-times ";; Function" 1 "fre2" } }
-// { dg-final { scan-tree-dump-times "free" 19 "fre2" } }
+// { dg-final { scan-tree-dump-times "free" 18 "fre2" } }
 // { dg-final { scan-tree-dump-times "unreachable" 11 "fre2" } }
 // { dg-final { cleanup-tree-dump "fre2" } }
Index: testsuite/g++.dg/warn/Warray-bounds.C
===================================================================
--- testsuite/g++.dg/warn/Warray-bounds.C	(revision 222016)
+++ testsuite/g++.dg/warn/Warray-bounds.C	(working copy)
@@ -11,6 +11,7 @@ static inline int n(void) {
 
 void g(int *p);
 void h(int p);
+void bar (void *);
 
 int* f(void) {
     int b[10];
@@ -27,6 +28,7 @@ int* f(void) {
     a[ 9] = 0;
     a[10] = 0;             /* { dg-warning "array subscript" } */
     a[11] = 0;             /* { dg-warning "array subscript" } */
+    bar (a);
     a[2 * n() - 11] = 1;    /* { dg-warning "array subscript" } */
     a[2 * n() - 10] = 1;
     a[2 * n() -  1] = 1;
@@ -38,6 +40,7 @@ int* f(void) {
     b[ 9] = 0;
     b[10] = 0;             /* { dg-warning "array subscript" } */
     b[11] = 0;             /* { dg-warning "array subscript" } */
+    bar (b);
     b[2 * n() - 11] = 1;    /* { dg-warning "array subscript" } */
     b[2 * n() - 10] = 1;
     b[2 * n() -  1] = 1;
@@ -49,6 +52,7 @@ int* f(void) {
     c.c[ 9] = 0;
     c.c[10] = 0;           /* { dg-warning "array subscript" } */
     c.c[11] = 0;           /* { dg-warning "array subscript" } */
+    bar (&c);
     c.c[2 * n() - 11] = 1;  /* { dg-warning "array subscript" } */
     c.c[2 * n() - 10] = 1;
     c.c[2 * n() -  1] = 1;
@@ -87,6 +91,8 @@ int* f(void) {
     if (-1 >= 0)
        c.c[-1] = 0;
 
+    bar (b);
+    bar (&c);
     return a;
 }
 
Index: testsuite/gcc.dg/Warray-bounds-11.c
===================================================================
--- testsuite/gcc.dg/Warray-bounds-11.c	(revision 222016)
+++ testsuite/gcc.dg/Warray-bounds-11.c	(working copy)
@@ -92,5 +92,11 @@ void foo(int (*a)[3])
 	bar(c);
 	bar(e);
 	bar(f.f);
+	bar(h1->j);
+	bar(h3->j);
+	bar(h3b->j);
+	bar(h1b->j);
+	bar(h->j);
+	bar(h0->j);
 }
 
Index: testsuite/gcc.dg/Warray-bounds.c
===================================================================
--- testsuite/gcc.dg/Warray-bounds.c	(revision 222016)
+++ testsuite/gcc.dg/Warray-bounds.c	(working copy)
@@ -11,6 +11,8 @@ static inline int n(void) {
 void g(int *p);
 void h(int p);
 
+void bar (void *);
+
 int* f(void) {
     int b[10];
     int i;
@@ -26,10 +28,12 @@ int* f(void) {
     a[ 9] = 0;
     a[10] = 0;             /* { dg-warning "6:array subscript" } */
     a[11] = 0;             /* { dg-warning "6:array subscript" } */
+    bar (a);
     a[2 * n() - 11] = 1;    /* { dg-warning "6:array subscript" } */
     a[2 * n() - 10] = 1;
     a[2 * n() -  1] = 1;
     a[2 * n() -  0] = 1;    /* { dg-warning "6:array subscript" } */
+    bar (a);
 
     b[-1] = 0;             /* { dg-warning "6:array subscript" } */
     b[ 0] = 0;
@@ -37,6 +41,7 @@ int* f(void) {
     b[ 9] = 0;
     b[10] = 0;             /* { dg-warning "6:array subscript" } */
     b[11] = 0;             /* { dg-warning "6:array subscript" } */
+    bar (b);
     b[2 * n() - 11] = 1;    /* { dg-warning "6:array subscript" } */
     b[2 * n() - 10] = 1;
     b[2 * n() -  1] = 1;
@@ -48,6 +53,7 @@ int* f(void) {
     c.c[ 9] = 0;
     c.c[10] = 0;           /* { dg-warning "8:array subscript" } */
     c.c[11] = 0;           /* { dg-warning "8:array subscript" } */
+    bar (&c);
     c.c[2 * n() - 11] = 1;  /* { dg-warning "8:array subscript" } */
     c.c[2 * n() - 10] = 1;
     c.c[2 * n() -  1] = 1;
@@ -88,6 +94,8 @@ int* f(void) {
     for (i = 20; i < 30; ++i)
              a[i] = 1;       /* { dg-warning "15:array subscript" } */
 
+    bar (b);
+    bar (&c);
     return a;
 }
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Add DSE to early passes
  2015-04-13 10:01 Add DSE to early passes Jan Hubicka
@ 2015-04-13 12:12 ` Richard Biener
  2015-04-22 12:13 ` H.J. Lu
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Biener @ 2015-04-13 12:12 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Mon, 13 Apr 2015, Jan Hubicka wrote:

> Hi,
> this patch adds DSE to early optimizations and handles testuiste fallout.
> As discussed in PR 65076 this reduces number of CLOBBER statements in tramp3d
> to 50% (and those accounts 29% of all code previously). The pass also quite
> often kills real stores reducing Firefox binary by over 2% due to
> better inline decisions.
> 
> Bootstrapped/regtested ppc64-linux, OK?

Ok, but please wait a bit with committing to maintain trunk as a
test-base for GCC 5 patches during the RC phase.

Thanks,
Richard.

> Honza
> 
> 	* passes.def (early_optimizations): Add pass_dse.
> 
> 	* g++.dg/tree-ssa/pr61034.C: Update template.
> 	* g++.dg/warn/Warray-bounds.C: Harden for DSE.
> 	* gcc.dg/Warray-bounds-11.c: Likewise.
> 	* gcc.dg/Warray-bounds.c: Likewise.
> Index: passes.def
> ===================================================================
> --- passes.def	(revision 222016)
> +++ passes.def	(working copy)
> @@ -89,6 +89,7 @@ along with GCC; see the file COPYING3.
>  	  NEXT_PASS (pass_build_ealias);
>  	  NEXT_PASS (pass_fre);
>  	  NEXT_PASS (pass_merge_phi);
> +          NEXT_PASS (pass_dse);
>  	  NEXT_PASS (pass_cd_dce);
>  	  NEXT_PASS (pass_early_ipa_sra);
>  	  NEXT_PASS (pass_tail_recursion);
> Index: testsuite/g++.dg/tree-ssa/pr61034.C
> ===================================================================
> --- testsuite/g++.dg/tree-ssa/pr61034.C	(revision 222016)
> +++ testsuite/g++.dg/tree-ssa/pr61034.C	(working copy)
> @@ -42,6 +42,6 @@ bool f(I a, I b, I c, I d) {
>  // This works only if everything is inlined into 'f'.
>  
>  // { dg-final { scan-tree-dump-times ";; Function" 1 "fre2" } }
> -// { dg-final { scan-tree-dump-times "free" 19 "fre2" } }
> +// { dg-final { scan-tree-dump-times "free" 18 "fre2" } }
>  // { dg-final { scan-tree-dump-times "unreachable" 11 "fre2" } }
>  // { dg-final { cleanup-tree-dump "fre2" } }
> Index: testsuite/g++.dg/warn/Warray-bounds.C
> ===================================================================
> --- testsuite/g++.dg/warn/Warray-bounds.C	(revision 222016)
> +++ testsuite/g++.dg/warn/Warray-bounds.C	(working copy)
> @@ -11,6 +11,7 @@ static inline int n(void) {
>  
>  void g(int *p);
>  void h(int p);
> +void bar (void *);
>  
>  int* f(void) {
>      int b[10];
> @@ -27,6 +28,7 @@ int* f(void) {
>      a[ 9] = 0;
>      a[10] = 0;             /* { dg-warning "array subscript" } */
>      a[11] = 0;             /* { dg-warning "array subscript" } */
> +    bar (a);
>      a[2 * n() - 11] = 1;    /* { dg-warning "array subscript" } */
>      a[2 * n() - 10] = 1;
>      a[2 * n() -  1] = 1;
> @@ -38,6 +40,7 @@ int* f(void) {
>      b[ 9] = 0;
>      b[10] = 0;             /* { dg-warning "array subscript" } */
>      b[11] = 0;             /* { dg-warning "array subscript" } */
> +    bar (b);
>      b[2 * n() - 11] = 1;    /* { dg-warning "array subscript" } */
>      b[2 * n() - 10] = 1;
>      b[2 * n() -  1] = 1;
> @@ -49,6 +52,7 @@ int* f(void) {
>      c.c[ 9] = 0;
>      c.c[10] = 0;           /* { dg-warning "array subscript" } */
>      c.c[11] = 0;           /* { dg-warning "array subscript" } */
> +    bar (&c);
>      c.c[2 * n() - 11] = 1;  /* { dg-warning "array subscript" } */
>      c.c[2 * n() - 10] = 1;
>      c.c[2 * n() -  1] = 1;
> @@ -87,6 +91,8 @@ int* f(void) {
>      if (-1 >= 0)
>         c.c[-1] = 0;
>  
> +    bar (b);
> +    bar (&c);
>      return a;
>  }
>  
> Index: testsuite/gcc.dg/Warray-bounds-11.c
> ===================================================================
> --- testsuite/gcc.dg/Warray-bounds-11.c	(revision 222016)
> +++ testsuite/gcc.dg/Warray-bounds-11.c	(working copy)
> @@ -92,5 +92,11 @@ void foo(int (*a)[3])
>  	bar(c);
>  	bar(e);
>  	bar(f.f);
> +	bar(h1->j);
> +	bar(h3->j);
> +	bar(h3b->j);
> +	bar(h1b->j);
> +	bar(h->j);
> +	bar(h0->j);
>  }
>  
> Index: testsuite/gcc.dg/Warray-bounds.c
> ===================================================================
> --- testsuite/gcc.dg/Warray-bounds.c	(revision 222016)
> +++ testsuite/gcc.dg/Warray-bounds.c	(working copy)
> @@ -11,6 +11,8 @@ static inline int n(void) {
>  void g(int *p);
>  void h(int p);
>  
> +void bar (void *);
> +
>  int* f(void) {
>      int b[10];
>      int i;
> @@ -26,10 +28,12 @@ int* f(void) {
>      a[ 9] = 0;
>      a[10] = 0;             /* { dg-warning "6:array subscript" } */
>      a[11] = 0;             /* { dg-warning "6:array subscript" } */
> +    bar (a);
>      a[2 * n() - 11] = 1;    /* { dg-warning "6:array subscript" } */
>      a[2 * n() - 10] = 1;
>      a[2 * n() -  1] = 1;
>      a[2 * n() -  0] = 1;    /* { dg-warning "6:array subscript" } */
> +    bar (a);
>  
>      b[-1] = 0;             /* { dg-warning "6:array subscript" } */
>      b[ 0] = 0;
> @@ -37,6 +41,7 @@ int* f(void) {
>      b[ 9] = 0;
>      b[10] = 0;             /* { dg-warning "6:array subscript" } */
>      b[11] = 0;             /* { dg-warning "6:array subscript" } */
> +    bar (b);
>      b[2 * n() - 11] = 1;    /* { dg-warning "6:array subscript" } */
>      b[2 * n() - 10] = 1;
>      b[2 * n() -  1] = 1;
> @@ -48,6 +53,7 @@ int* f(void) {
>      c.c[ 9] = 0;
>      c.c[10] = 0;           /* { dg-warning "8:array subscript" } */
>      c.c[11] = 0;           /* { dg-warning "8:array subscript" } */
> +    bar (&c);
>      c.c[2 * n() - 11] = 1;  /* { dg-warning "8:array subscript" } */
>      c.c[2 * n() - 10] = 1;
>      c.c[2 * n() -  1] = 1;
> @@ -88,6 +94,8 @@ int* f(void) {
>      for (i = 20; i < 30; ++i)
>               a[i] = 1;       /* { dg-warning "15:array subscript" } */
>  
> +    bar (b);
> +    bar (&c);
>      return a;
>  }
>  
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild,
Dilip Upmanyu, Graham Norton HRB 21284 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Add DSE to early passes
  2015-04-13 10:01 Add DSE to early passes Jan Hubicka
  2015-04-13 12:12 ` Richard Biener
@ 2015-04-22 12:13 ` H.J. Lu
  2015-04-22 12:17   ` Jan Hubicka
  1 sibling, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2015-04-22 12:13 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Richard Guenther, GCC Patches

On Mon, Apr 13, 2015 at 3:01 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this patch adds DSE to early optimizations and handles testuiste fallout.
> As discussed in PR 65076 this reduces number of CLOBBER statements in tramp3d
> to 50% (and those accounts 29% of all code previously). The pass also quite
> often kills real stores reducing Firefox binary by over 2% due to
> better inline decisions.
>
> Bootstrapped/regtested ppc64-linux, OK?
>
> Honza
>
>         * passes.def (early_optimizations): Add pass_dse.
>
>         * g++.dg/tree-ssa/pr61034.C: Update template.
>         * g++.dg/warn/Warray-bounds.C: Harden for DSE.
>         * gcc.dg/Warray-bounds-11.c: Likewise.
>         * gcc.dg/Warray-bounds.c: Likewise.
> Index: passes.def
> ===================================================================
> --- passes.def  (revision 222016)
> +++ passes.def  (working copy)
> @@ -89,6 +89,7 @@ along with GCC; see the file COPYING3.
>           NEXT_PASS (pass_build_ealias);
>           NEXT_PASS (pass_fre);
>           NEXT_PASS (pass_merge_phi);
> +          NEXT_PASS (pass_dse);
>           NEXT_PASS (pass_cd_dce);
>           NEXT_PASS (pass_early_ipa_sra);
>           NEXT_PASS (pass_tail_recursion);
> Index: testsuite/g++.dg/tree-ssa/pr61034.C
> ===================================================================
> --- testsuite/g++.dg/tree-ssa/pr61034.C (revision 222016)
> +++ testsuite/g++.dg/tree-ssa/pr61034.C (working copy)
> @@ -42,6 +42,6 @@ bool f(I a, I b, I c, I d) {
>  // This works only if everything is inlined into 'f'.
>
>  // { dg-final { scan-tree-dump-times ";; Function" 1 "fre2" } }
> -// { dg-final { scan-tree-dump-times "free" 19 "fre2" } }
> +// { dg-final { scan-tree-dump-times "free" 18 "fre2" } }
>  // { dg-final { scan-tree-dump-times "unreachable" 11 "fre2" } }
>  // { dg-final { cleanup-tree-dump "fre2" } }

I got

FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++11  scan-tree-dump-times
fre2 "free" 18
FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++14  scan-tree-dump-times
fre2 "free" 18
FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++98  scan-tree-dump-times
fre2 "free" 18

on Linux/x86.


-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Add DSE to early passes
  2015-04-22 12:13 ` H.J. Lu
@ 2015-04-22 12:17   ` Jan Hubicka
  2015-04-22 12:27     ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Hubicka @ 2015-04-22 12:17 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Jan Hubicka, Richard Guenther, GCC Patches

> > @@ -42,6 +42,6 @@ bool f(I a, I b, I c, I d) {
> >  // This works only if everything is inlined into 'f'.
> >
> >  // { dg-final { scan-tree-dump-times ";; Function" 1 "fre2" } }
> > -// { dg-final { scan-tree-dump-times "free" 19 "fre2" } }
> > +// { dg-final { scan-tree-dump-times "free" 18 "fre2" } }
> >  // { dg-final { scan-tree-dump-times "unreachable" 11 "fre2" } }
> >  // { dg-final { cleanup-tree-dump "fre2" } }
> 
> I got
> 
> FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++11  scan-tree-dump-times
> fre2 "free" 18
> FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++14  scan-tree-dump-times
> fre2 "free" 18
> FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++98  scan-tree-dump-times
> fre2 "free" 18
> 
> on Linux/x86.

Hmm, I tested on pcc64, but now I see the same failure on x86-64.
Perhaps this testcase became target sensitive?
Richard, does the count really matter?

Honza

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Add DSE to early passes
  2015-04-22 12:17   ` Jan Hubicka
@ 2015-04-22 12:27     ` Richard Biener
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2015-04-22 12:27 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: H.J. Lu, GCC Patches

On Wed, 22 Apr 2015, Jan Hubicka wrote:

> > > @@ -42,6 +42,6 @@ bool f(I a, I b, I c, I d) {
> > >  // This works only if everything is inlined into 'f'.
> > >
> > >  // { dg-final { scan-tree-dump-times ";; Function" 1 "fre2" } }
> > > -// { dg-final { scan-tree-dump-times "free" 19 "fre2" } }
> > > +// { dg-final { scan-tree-dump-times "free" 18 "fre2" } }
> > >  // { dg-final { scan-tree-dump-times "unreachable" 11 "fre2" } }
> > >  // { dg-final { cleanup-tree-dump "fre2" } }
> > 
> > I got
> > 
> > FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++11  scan-tree-dump-times
> > fre2 "free" 18
> > FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++14  scan-tree-dump-times
> > fre2 "free" 18
> > FAIL: g++.dg/tree-ssa/pr61034.C  -std=gnu++98  scan-tree-dump-times
> > fre2 "free" 18
> > 
> > on Linux/x86.
> 
> Hmm, I tested on pcc64, but now I see the same failure on x86-64.
> Perhaps this testcase became target sensitive?
> Richard, does the count really matter?

Well, it verifies that (part) of the desired optimization happens.
I can't see what should be target dependent here though.

Richard.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-22 12:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 10:01 Add DSE to early passes Jan Hubicka
2015-04-13 12:12 ` Richard Biener
2015-04-22 12:13 ` H.J. Lu
2015-04-22 12:17   ` Jan Hubicka
2015-04-22 12:27     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).