This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] invariant expressions in loop at depth zero


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
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]