Bug 18048 - [4.0/4.1/4.2 Regression] mgrid loop performance regression with ivopts (register pressure)
Summary: [4.0/4.1/4.2 Regression] mgrid loop performance regression with ivopts (regis...
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.3
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
: 20945 (view as bug list)
Depends on: 19038 19701
Blocks: 18693 20945
  Show dependency treegraph
 
Reported: 2004-10-18 19:22 UTC by David Edelsohn
Modified: 2005-12-18 14:30 UTC (History)
8 users (show)

See Also:
Host: *-*-*
Target: *-*-*
Build: *-*-*
Known to work:
Known to fail:
Last reconfirmed: 2005-07-01 22:13:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Edelsohn 2004-10-18 19:22:36 UTC
172.mgrid performance degraded after ivopts were introduced.  The patch to 
improve iv selection did not improve the performance.  This is separate from 
the register pressure problems.  The tree loop optimization appears to be 
leaving unnecessary computations in loops.
Comment 1 Michael Matz 2004-10-19 16:46:04 UTC
Does this go away with "--param iv-consider-all-candidates-bound=70" ? 
(Or with a higher number like 100 or 1000) 
Comment 2 Andrew Pinski 2004-10-22 17:35:48 UTC
I think this can be confirmed because you can see the drop on Diego's SPEC tester:
<http://people.redhat.com/dnovillo/spec2000/gcc/individual-run-ratio.html>.
Comment 3 David Edelsohn 2004-10-22 18:39:11 UTC
Daniel's DOM loop depth patch might help with this problem as well.
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00931.html
Comment 4 Zdenek Dvorak 2004-10-22 21:16:04 UTC
Subject: Re:  [4.0 Regression] mgrid loop performance regression with ivopts

> Daniel's DOM loop depth patch might help with this problem as well.
> http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00931.html

Probably not (although large part of the regression is indeed caused by
ivopts -- dom interaction, it seems to be of quite different type).

I am just testing a patch that significantly decreases the regression
(unfortunately, some 10% remain even with the patch; hopefully I will
find reason for them soon).

Zdenek
Comment 5 GCC Commits 2004-10-27 20:27:27 UTC
Subject: Bug 18048

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rakdver@gcc.gnu.org	2004-10-27 20:27:21

Modified files:
	gcc            : ChangeLog fold-const.c tree-ssa-loop-ivopts.c 
	                 tree-ssa-loop-niter.c tree.c tree.h 

Log message:
	PR tree-optimization/18048
	* fold-const.c (try_move_mult_to_index): New function.
	(fold): Use try_move_mult_to_index.
	* tree-ssa-loop-ivopts.c (try_add_cand_for): Prefer common candidates.
	* tree-ssa-loop-niter.c (number_of_iterations_cond): Produce
	an all-ones unsigned constant without extra bits.
	* tree.c (build_low_bits_mask): New function.
	* tree.h (build_low_bits_mask): Declare.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6052&r2=2.6053
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.468&r2=1.469
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop-ivopts.c.diff?cvsroot=gcc&r1=2.20&r2=2.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop-niter.c.diff?cvsroot=gcc&r1=2.13&r2=2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.440&r2=1.441
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.640&r2=1.641

Comment 6 Andrew Pinski 2004-12-26 14:50:26 UTC
PR 19038 shows up here also but not introduced by ivopts related.
Comment 7 Andrew Pinski 2004-12-26 14:58:31 UTC
(In reply to comment #6)
> PR 19038 shows up here also but not introduced by ivopts related.
Though IV-OPTS helps fixing some of these.
Comment 8 Andrew Pinski 2005-01-06 23:02:07 UTC
Actually I think the remaining issues of the mgrid performance regression are caused by PR 19038.
Comment 9 Andrew Pinski 2005-01-22 17:54:38 UTC
(In reply to comment #8)
> Actually I think the remaining issues of the mgrid performance regression are caused by PR 19038.

Well I looked the assembly and it looks like a regresiter allocator problem now because with -fno-
ivopts we don't spill but with it turned we do.
Comment 10 Andrew Pinski 2005-01-22 21:37:07 UTC
If I have a smaller testcase but the loop is still looks like what is in mgrid can I paste it here, it is only 
30 lines?
Comment 11 Steven Bosscher 2005-01-23 00:24:36 UTC
The mgrid score on AMD64 jumps 30% with my patch for PR19464 applied. 
Comment 12 Steven Bosscher 2005-01-23 13:17:08 UTC
Andrew, 30 lines is quite OK to paste if you rename things a bit ;-) 
You'll find that mgrid.f is already available on the web anyway: 
http://www.cs.duke.edu/~tavi/scheduling/mgrid.f 
Comment 13 Andrew Pinski 2005-01-30 04:36:50 UTC
PR 19701 is an example of where ivopts causes a regression in that we create too many IVs.
Comment 14 Andrew Pinski 2005-02-10 21:15:42 UTC
I looked at the code generation after Zdenek's patch for PR 19701 and it looks much better but I don't 
have a machine to test SPEC on.
Comment 15 Steven Bosscher 2005-02-14 10:22:48 UTC
Is this fixed now? 
Comment 16 Andrew Pinski 2005-02-14 15:52:01 UTC
(In reply to comment #15)
> Is this fixed now? 
No, it regressed again.
See <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00507.html>.
Comment 17 David Edelsohn 2005-02-14 16:03:40 UTC
With -O2/-O3 -funroll loops -fswitch-loops -fpeel-loops, mgrid (and swim) no 
longer regress.  With just -O2/-O3, performance regression for mgrid remains 
(and swim performance dropped dramatically).
Comment 18 Steven Bosscher 2005-10-17 09:27:00 UTC
*** Bug 20945 has been marked as a duplicate of this bug. ***
Comment 19 Mark Mitchell 2005-10-31 00:41:19 UTC
Leaving as P2, since this is a SPEC benchmark issue, which many potential users and reviewers use to judge GCC performance.
Comment 20 Steven Bosscher 2005-11-14 00:28:31 UTC
Is this still a problem?  The SPEC graph for mgrid on PPC has moved up lately:
http://www.suse.de/~gcctest/SPEC/CFP/sb-huckleberry2-head-64/172_mgrid_big.png
Comment 21 David Edelsohn 2005-11-14 01:58:14 UTC
Subject: Re:  [4.0/4.1 Regression] mgrid loop performance regression with ivopts (register pressure) 

And mesa has taken a performance dive...
Comment 22 Steven Bosscher 2005-11-14 10:36:59 UTC
Yes, mesa is down.  But is that related to this bug?
Comment 23 Steven Bosscher 2005-12-18 14:30:29 UTC
This bug was for mgrid, but now we're stuck on a reported mesa performance drop that may or may not be related to this PR.  I suggest that if the mesa drop is still there, a new bug report should be opened for it.