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.
Created attachment 8060 [details] testcase The testcase is reduced from a complex POOMA program.
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).
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.
I guess making PRE and ivopts playing nicely together perfectly is near to impossible - but any improvement in the 4.0 timeframe is welcome!
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! >
El Fixed
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
This pach doesn't have a ChangeLog.