Bug 33562 - [6 Regression] aggregate DSE disabled
Summary: [6 Regression] aggregate DSE disabled
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 7.4
Assignee: Jeffrey A. Law
URL:
Keywords: missed-optimization, xfail
Depends on: 30375
Blocks: 77485
  Show dependency treegraph
 
Reported: 2007-09-26 11:55 UTC by Richard Biener
Modified: 2018-04-30 23:11 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2009-09-28 21:39:34


Attachments
restore DCE of killing defs (565 bytes, patch)
2007-09-27 10:17 UTC, Richard Biener
Details | Diff
more complete patch to resture DCE of killing defs (1.14 KB, patch)
2007-09-27 13:38 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2007-09-26 11:55:50 UTC
Author: rguenth
Date: Wed Sep 26 11:55:17 2007
New Revision: 128810

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128810
Log:
2007-09-26  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/30375
	PR tree-optimization/33560
...
        * gcc.dg/tree-ssa/complex-4.c: XFAIL.
        * gcc.dg/tree-ssa/complex-5.c: Likewise.
        * gcc.dg/tree-ssa/ssa-dse-9.c: Likewise.
Comment 1 Andrew Pinski 2007-09-26 19:04:15 UTC
        * gcc.dg/tree-ssa/complex-4.c: XFAIL.
is a regression then because the testcase was added back in 2006-02-18 (by me).
Comment 2 rguenther@suse.de 2007-09-27 09:08:17 UTC
Subject: Re:  [4.3 Regression] aggregate DSE
 disabled

On Wed, 26 Sep 2007, pinskia at gcc dot gnu dot org wrote:

> ------- Comment #1 from pinskia at gcc dot gnu dot org  2007-09-26 19:04 -------
>         * gcc.dg/tree-ssa/complex-4.c: XFAIL.
> is a regression then because the testcase was added back in 2006-02-18
> (by me).

I did wonder what optimized that before...  (maybe a separate bug for
this is more appropriate)

Richard.
Comment 3 pinskia@gmail.com 2007-09-27 09:19:26 UTC
Subject: Re:  [4.3 Regression] aggregate DSE disabled

On 27 Sep 2007 09:08:17 -0000, rguenther at suse dot de
<gcc-bugzilla@gcc.gnu.org> wrote:
> I did wonder what optimized that before...  (maybe a separate bug for
> this is more appropriate)

Must_def cause the optimization to work IIRC.  In fact this is the
reason why aggregate DSE was added was specifically to fix this
testcase.

See http://gcc.gnu.org/ml/gcc-patches/2006-05/msg01115.html which
specifically mentions this.  I am still trying to understand why we
removed must_def anyways.  Everything points to the removal of
must_def caused many different regressions.

Thanks,
Andrew Pinski
Comment 4 Richard Biener 2007-09-27 10:17:49 UTC
Created attachment 14254 [details]
restore DCE of killing defs

some ssa updating is broken in dce though:

/space/rguenther/src/svn/pointer_plus/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c: In function 'f':
/space/rguenther/src/svn/pointer_plus/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c:5: error: type mismatch between an SSA_NAME and its symbol
/space/rguenther/src/svn/pointer_plus/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c:5: error: in statement
# SFT.1_12 = VDEF <SFT.1_11> { SFT.1 }
REALPART_EXPR <t> = 2;
/space/rguenther/src/svn/pointer_plus/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c:5: internal compiler error: verify_ssa failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

but dceloop now removes the dead store and we get:

f ()
{
  complex int t;
  int D.1551;

<bb 2>:
  # SFT.1_12 = VDEF <SFT.1_11>
  REALPART_EXPR <t> = 2;
  # SFT.0_13 = VDEF <SFT.0_10>
  IMAGPART_EXPR <t> = 2;
  # SFT.0_14 = VDEF <SFT.0_13>
  # SFT.1_15 = VDEF <SFT.1_12>
  D.1551_5 = g (&t);
  return D.1551_5;

}
Comment 5 Richard Biener 2007-09-27 13:38:00 UTC
Created attachment 14256 [details]
more complete patch to resture DCE of killing defs

It still breaks in some cases.  With the unfortunate fact that we need the
VMAYUSEs even for killing defs we might end up to need to do a two-phase DCE
for those :/  (See the special casing of PHI_NODEs in the patch, it seems some
more special casing is missing)
Comment 6 Richard Biener 2007-09-27 13:42:11 UTC
Diego, it sucks that we need to jump through hoops to get V_MUST_DEF "back".
Comment 7 dnovillo@google.com 2007-09-27 13:48:02 UTC
Subject: Re:  [4.3 Regression] aggregate DSE disabled

On 27 Sep 2007 13:42:11 -0000, rguenth at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:

> Diego, it sucks that we need to jump through hoops to get V_MUST_DEF "back".

Unless we can prove that it is impossible to implement DSE any other
way, I would prefer to keep virtual SSA as simple as possible.  It's
meant as a safety net and a "good enough" UD web for passes that do
not care for being too aggressive.
Comment 8 rguenther@suse.de 2007-09-27 14:01:16 UTC
Subject: Re:  [4.3 Regression] aggregate DSE
 disabled

On Thu, 27 Sep 2007, dnovillo at google dot com wrote:

> ------- Comment #7 from dnovillo at google dot com  2007-09-27 13:48 -------
> Subject: Re:  [4.3 Regression] aggregate DSE disabled
> 
> On 27 Sep 2007 13:42:11 -0000, rguenth at gcc dot gnu dot org
> <gcc-bugzilla@gcc.gnu.org> wrote:
> 
> > Diego, it sucks that we need to jump through hoops to get V_MUST_DEF "back".
> 
> Unless we can prove that it is impossible to implement DSE any other
> way, I would prefer to keep virtual SSA as simple as possible.  It's
> meant as a safety net and a "good enough" UD web for passes that do
> not care for being too aggressive.

I sort-of agree.  Still DCE was able to handle tree-ssa/complex-4.c
before we removed V_MUST_DEF.  Which is what I'm trying to get back.

As "good enough" UD web it would be nice to have only single VDEFs on
stores (I don't care for clobbers at call sites).  Though finding the
optimal static partitioning to ensure this is probably hard?

Richard.
Comment 9 dnovillo@google.com 2007-09-27 14:12:29 UTC
Subject: Re:  [4.3 Regression] aggregate DSE disabled

On 27 Sep 2007 14:01:18 -0000, rguenther at suse dot de
<gcc-bugzilla@gcc.gnu.org> wrote:

> I sort-of agree.  Still DCE was able to handle tree-ssa/complex-4.c
> before we removed V_MUST_DEF.  Which is what I'm trying to get back.

Yeah, it is somewhat tempting to make the infrastructure more powerful
because you suddenly get more out of seemingly innocent passes.
However, a more powerful infrastructure creates problems of its own,
it needs to be maintained and it causes slowdowns even in passes that
do not need all the expressive power.

> As "good enough" UD web it would be nice to have only single VDEFs on
> stores (I don't care for clobbers at call sites).  Though finding the
> optimal static partitioning to ensure this is probably hard?

Yeah, that is the whole motivation behind the dynamic aspects of
mem-ssa, but getting it right has proven tricky.  Unfortunately, I
have not had time to come back to that idea in some time.
Comment 10 Richard Biener 2007-09-28 09:41:51 UTC
Last patch before I stopped working on enhancing DCE:
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01978.html
Comment 11 Richard Biener 2008-03-14 17:02:05 UTC
We won't fix this on the 4.3 branch.
Comment 12 Richard Biener 2009-01-08 22:56:27 UTC
Neither for GCC 4.4.  Re-targeting for GCC 4.5.
Comment 13 Richard Biener 2010-04-06 11:19:34 UTC
GCC 4.5.0 is being released.  Deferring to 4.5.1.
Comment 14 Richard Biener 2010-07-31 09:29:15 UTC
GCC 4.5.1 is being released, adjusting target milestone.
Comment 15 Richard Biener 2010-12-16 13:03:50 UTC
GCC 4.5.2 is being released, adjusting target milestone.
Comment 16 Richard Biener 2011-04-28 14:51:55 UTC
GCC 4.5.3 is being released, adjusting target milestone.
Comment 17 Richard Biener 2012-07-02 12:26:05 UTC
The 4.5 branch is being closed, adjusting target milestone.
Comment 18 Jakub Jelinek 2013-04-12 15:16:35 UTC
GCC 4.6.4 has been released and the branch has been closed.
Comment 19 Richard Biener 2014-06-12 13:44:17 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 20 Jakub Jelinek 2014-12-19 13:27:35 UTC
GCC 4.8.4 has been released.
Comment 21 Richard Biener 2015-06-23 08:16:56 UTC
The gcc-4_8-branch is being closed, re-targeting regressions to 4.9.3.
Comment 22 Jakub Jelinek 2015-06-26 19:53:27 UTC
GCC 4.9.3 has been released.
Comment 23 Jeffrey A. Law 2016-02-22 18:09:29 UTC
Pushing this to a P4 given that the regression, while real, is very rare in real world code.

A fix for the regression as well as further enhancements to DSE is queued for gcc-7.
Comment 24 Richard Biener 2016-02-23 08:29:17 UTC
(In reply to Jeffrey A. Law from comment #23)
> Pushing this to a P4 given that the regression, while real, is very rare in
> real world code.
> 
> A fix for the regression as well as further enhancements to DSE is queued
> for gcc-7.

Please leave such kind of bugs at P2, they are not blocking the release and
criteria for prioritization are here: https://gcc.gnu.org/bugs/management.html
Comment 25 Jeffrey A. Law 2017-01-13 15:37:41 UTC
Author: law
Date: Fri Jan 13 15:37:09 2017
New Revision: 244441

URL: https://gcc.gnu.org/viewcvs?rev=244441&root=gcc&view=rev
Log:
	PR tree-optimization/33562
	PR tree-optimization/61912
	PR tree-optimization/77485
	* sbitmap.h (bitmap_count_bits): Prototype.
	(bitmap_clear_range, bitmap_set_range): Likewise.
	* sbitmap.c (bitmap_clear_range): New function.
	(bitmap_set_range, sbitmap_popcount, bitmap_count_bits): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sbitmap.c
    trunk/gcc/sbitmap.h
Comment 26 Jeffrey A. Law 2017-01-13 15:42:40 UTC
Author: law
Date: Fri Jan 13 15:42:08 2017
New Revision: 244442

URL: https://gcc.gnu.org/viewcvs?rev=244442&root=gcc&view=rev
Log:
        PR tree-optimization/33562
        PR tree-optimization/61912
        PR tree-optimization/77485
	* doc/invoke.texi: Document new dse-max-object-size param.
	* params.def (PARM_DSE_MAX_OBJECT_SIZE): New PARAM.
	* tree-ssa-dse.c: Include params.h.
	(dse_store_status): New enum.
	(initialize_ao_ref_for_dse): New, partially extracted from
	dse_optimize_stmt.
	(valid_ao_ref_for_dse, normalize_ref): New.
	(setup_live_bytes_from_ref, compute_trims): Likewise.
	(clear_bytes_written_by, maybe_trim_complex_store): Likewise.
	(maybe_trim_partially_dead_store): Likewise.
	(maybe_trim_complex_store): Likewise.
	(dse_classify_store): Renamed from dse_possibly_dead_store_p.
	Track what bytes live from the original store.  Return tri-state
	for dead, partially dead or live.
	(dse_dom_walker): Add constructor, destructor and new private members.
	(delete_dead_call, delete_dead_assignment): New extracted from
	dse_optimize_stmt.
	(dse_optimize_stmt): Make a member of dse_dom_walker.
	Use initialize_ao_ref_for_dse.

        PR tree-optimization/33562
        PR tree-optimization/61912
        PR tree-optimization/77485
	* gcc.dg/tree-ssa/complex-4.c: Remove xfail.
	* gcc.dg/tree-ssa/complex-5.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dse-9.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dse-18.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-19.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dse-20.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dse-21.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-18.c
      - copied, changed from r244441, trunk/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-19.c
      - copied, changed from r244441, trunk/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-20.c
      - copied, changed from r244441, trunk/gcc/testsuite/gcc.dg/tree-ssa/complex-5.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-21.c
      - copied, changed from r244441, trunk/gcc/testsuite/gcc.dg/tree-ssa/complex-5.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/invoke.texi
    trunk/gcc/params.def
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/complex-4.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/complex-5.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-9.c
    trunk/gcc/tree-ssa-dse.c
Comment 27 Jeffrey A. Law 2017-01-13 15:43:06 UTC
Fixed on the trunk.  No plans to backport.
Comment 28 Martin Sebor 2017-01-13 22:43:47 UTC
Based on comment #26 and comment #27 it sounds as though this is resolved.
Comment 29 Jeffrey A. Law 2017-01-13 23:16:15 UTC
It's still a regression for 5/6, so it should stay open until those releases are no longer supported.  Note the "7" in the regression marker is gone.
Comment 30 Jeffrey A. Law 2017-01-14 06:16:58 UTC
Author: law
Date: Sat Jan 14 06:16:23 2017
New Revision: 244461

URL: https://gcc.gnu.org/viewcvs?rev=244461&root=gcc&view=rev
Log:
	PR tree-optimization/33562
	PR tree-optimization/61912
	PR tree-optimization/77485
	* tree-ssa-dse.c (delete_dead_call): Accept gsi rather than
	a statement.
	(delete_dead_assignment): Likewise.
	(dse_dom_walker::dse_optimize_stmt): Pass in the gsi rather than
	statement to delete_dead_call and delete_dead_assignment.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-dse.c
Comment 31 Martin Sebor 2017-01-14 17:20:22 UTC
(In reply to Jeffrey A. Law from comment #29)
> It's still a regression for 5/6, so it should stay open until those releases
> are no longer supported.  Note the "7" in the regression marker is gone.

Sorry, I didn't know about this policy.
Comment 32 Jeffrey A. Law 2017-01-16 23:43:37 UTC
Author: law
Date: Mon Jan 16 23:43:05 2017
New Revision: 244509

URL: https://gcc.gnu.org/viewcvs?rev=244509&root=gcc&view=rev
Log:
2017-01-16  Jeff Law  <law@redhat.com>

	PR tree-optimization/79090
	PR tree-optimization/33562
	PR tree-optimization/61912
	PR tree-optimization/77485
	* tree-ssa-dse.c (compute_trims): Accept STMT argument.  Dump STMT
	and computed trims into the dump file.

	PR tree-optimization/79090
	PR tree-optimization/33562
	PR tree-optimization/61912
	PR tree-optimization/77485
	* tree-ssa-dse.c (compute_trims): Accept STMT argument.  Dump STMT
	and computed trims into the dump file.

Added:
    trunk/gcc/testsuite/g++.dg/tree-ssa/ssa-dse-2.C
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-dse.c
Comment 33 Jakub Jelinek 2017-05-02 15:58:53 UTC
GCC 7.1 has been released.
Comment 34 Richard Biener 2018-01-25 08:25:35 UTC
GCC 7.3 is being released, adjusting target milestone.
Comment 35 Jeffrey A. Law 2018-04-30 23:11:38 UTC
We're not going to backport this any of the release branches.