Bug 36009 - PRE causes missed loop store motion, store sinking doesn't work
Summary: PRE causes missed loop store motion, store sinking doesn't work
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on: 36204
Blocks: 31738
  Show dependency treegraph
 
Reported: 2008-04-22 14:41 UTC by Richard Biener
Modified: 2008-05-15 08:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-04-22 14:41:27 UTC
double a[16][64], y[64], x[16];
void foo(void)
{
  int i, j;
  for (j = 0; j < 64; ++j)
    for (i = 0; i < 16; ++i)
      y[j] = y[j] + a[i][j] * x[i];
}

PRE moves the load of y[j] out of the inner loop like

    pretmp = y[j];
    for (i = 0; i < 16; ++i)
      {
        D.xxx = pretmp + a[i][j] * x[i];
        storetmp = D.xxx;
        y[j] = storetmp;
      }

which makes loop store motion no longer apply (store sinking is too
broken to fix this as well).
Comment 1 Andrew Pinski 2008-05-11 17:51:33 UTC
I bet this is a regression in fact and not really an enhancement.  Lim  was doing the store motion in previous versions of GCC but was disabled when the aliasing oracle patch went in (there was no explication for that part of the change).
Comment 2 Richard Biener 2008-05-15 08:38:07 UTC
Subject: Bug 36009

Author: rguenth
Date: Thu May 15 08:37:22 2008
New Revision: 135330

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135330
Log:
2008-05-15  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/36009
	PR tree-optimization/36204
	* tree-ssa-loop-im.c (tree-ssa-propagate.h): Include.
	(determine_invariantness_stmt): Record the loop a store is
	always executed in.
	* Makefile.in (tree-ssa-loop-im.o): Add tree-ssa-propagate.h
	dependency.

	* gcc.dg/tree-ssa/ssa-lim-5.c: New testcase.
	* gcc.dg/tree-ssa/ssa-lim-6.c: Likewise..

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-5.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-6.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-loop-im.c

Comment 3 Richard Biener 2008-05-15 08:41:52 UTC
Fixed.