Bug 19624 - PRE pessimizes ivopts
Summary: PRE pessimizes ivopts
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Daniel Berlin
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2005-01-25 14:44 UTC by Richard Biener
Modified: 2005-01-30 20:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-01-25 15:23:01


Attachments
testcase (2.58 KB, text/plain)
2005-01-25 14:45 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2005-01-25 14:44:33 UTC
The attached testcase is pessimized by PRE.  Be sure to get tree-level complete
loop unrolling enabled, f.i. with -O2 -funroll-loops with current mainline.

With PRE, a lot less computations are hoisted out of the inner loop.  Note this
is not a regression to 3.4, which is not able to decompose Loc<Dim> appropriately
or avoid instantiating temporary objects of this type.
Comment 1 Richard Biener 2005-01-25 14:45:32 UTC
Created attachment 8060 [details]
testcase

The testcase is reduced from a complex POOMA program.
Comment 2 Richard Biener 2005-01-25 14:52:34 UTC
Oh, in principle this should compile to roughly the same as

void c_test(double *a, double *b, int ei, int ej, int stridea, int strideb)
{
  for (int j=0; j<ej; ++j)
    for (int i=0; i<ei; ++i)
      a[i+j*stridea] = 0.5*(b[i+1+j*strideb] + b[i+(j+1)*strideb]);
}

... in principle (for the above -fno-tree-pre helps, too).
Comment 3 Daniel Berlin 2005-01-25 15:23:00 UTC
Just as an FYI, i have absoutely no plans to make it so ivopts and PRE interact
perfectly.
I only plan to disable transforms in PRE that are always unprofitable.
Comment 4 Richard Biener 2005-01-25 15:27:09 UTC
I guess making PRE and ivopts playing nicely together perfectly is near to
impossible - but any improvement in the 4.0 timeframe is welcome!
Comment 5 Daniel Berlin 2005-01-25 15:35:39 UTC
Subject: Re:  PRE pessimizes ivopts

On Tue, 2005-01-25 at 15:27 +0000, rguenth at tat dot physik dot
uni-tuebingen dot de wrote:
> ------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de  2005-01-25 15:27 -------
> I guess making PRE and ivopts playing nicely together perfectly is near to
> impossible

Yes, hence why i don't plan on promising it :)
There are always optimization interactions that are very very hard to
control or predict.
The best you can do is not make your optimization do things that are
always unprofitable, try to make them interact better where possible,
and hope for the best.

>  - but any improvement in the 4.0 timeframe is welcome!
> 

Comment 6 Daniel Berlin 2005-01-30 19:08:58 UTC
El Fixed
Comment 7 GCC Commits 2005-01-30 19:09:19 UTC
Subject: Bug 19624

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dberlin@gcc.gnu.org	2005-01-30 19:08:37

Modified files:
	gcc            : Makefile.in tree-ssa-pre.c 
Added files:
	gcc/testsuite/gcc.dg/tree-ssa: ssa-pre-4.c ssa-pre-5.c 
	                               ssa-pre-6.c 

Log message:
	2005-01-30  Daniel Berlin  <dberlin@dberlin.org>
	
	Fix PR tree-optimization/19624
	
	* Makefile.in (tree-ssa-pre.o): Add CFGLOOP_H.
	* tree-ssa-pre.c: Add cfgloop.h.
	Update comment.
	(pre_stats): New member, constified.
	(inserted_exprs): New static variable.
	(NECESSARY): New macro.
	(create_expression_by_pieces): Fold the expression, and
	mark it as defaulting to not necessary. Also put in
	inserted_exprs.
	(fully_constant_expression): New function.
	(insert_into_preds_of_block): Modify to not insert phis when we
	are playing with induction variables.
	Push phis onto the inserted_exprs vector, and mark them as not
	necessary by default.
	(insert_aux): Call fully_constant_expression on eprime.
	If all edges produce the same value, mark it constant.
	(mark_operand_necessary): New function.
	(remove_dead_inserted_code): New function.
	(init_pre): Init loop optimizer to get loop info.
	(fini_pre): Free loop_optimizer, and inserted_exprs vec.
	(execute_pre): Commit edge inserts, then remove dead code.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/Makefile.in.diff?cvsroot=gcc&r1=1.1444&r2=1.1445
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-pre.c.diff?cvsroot=gcc&r1=2.62&r2=2.63
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-4.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-5.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-6.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 Steven Bosscher 2005-01-30 20:56:42 UTC
This pach doesn't have a ChangeLog.