This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] invariant expressions in loop at depth zero
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Sebastian Pop" <sebpop at gmail dot com>
- Cc: "Zdenek Dvorak" <rakdver at kam dot mff dot cuni dot cz>, "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 29 Feb 2008 17:12:43 +0100
- Subject: Re: [patch] invariant expressions in loop at depth zero
- References: <cb9d34b20802290709k63591479m881caa278cbb388f@mail.gmail.com>
On Fri, Feb 29, 2008 at 4:09 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> Hi,
>
> I would like to slightly modify expr_invariant_in_loop_p such that it
> returns true for SSA_NAMEs that are defined in loop_0, the body of the
> function. This loop is executed exactly once, and thus the variables
> defined in loop_0 are not varying. I've sent the attached patch to
> regstrap.
>
> This occured on a simple testcase on which I was working on in the
> graphite branch, where a parameter N was defined outside the loops,
> and not detected as invariant:
>
> int foo (void);
> void bar (void);
>
> int toto()
> {
> int i, j, k;
> int a[100][100];
> int b[100];
> int N = foo ();
>
> for (i = 0; i < 2*N+ 100; i++)
> for (j = 0; j < 200; j++)
> a[j][i] = a[j+1][10] + 2;
>
> return a[3][5] + b[1];
> }
>
> Is this patch okay for trunk after regstrap?
This doesn't look right. It won't work for loop 0 then. Why does
flow_bb_inside_loop_p return true for your case? This seems to
be the place to fix it.
Richard.
> Thanks,
> Sebastian
> --
> AMD - GNU Tools
>