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: [lno] Swim loop reduced and heuristics problem


Another problem with the data dependence analysis is triggered by the
following testcase:

double u[1782225];

void foo (int N, double *res)
{
  int i, j;
  double sum = 0;

  for ( ; 1; )
    {
      for (i = 0; i < N; i++)
	{
	  for (j = 0; j < N; j++)
	    {
	      sum = sum + u[i + 1335 * j];
	    }
	  u[1336 * i] *= 2;
	}
      *res = sum + N;
    }
}

where we try to optimize only the sub-loop-nest.  This fixes the ICE.


Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 1.1.2.37
diff -c -c -p -r1.1.2.37 tree-data-ref.c
*** tree-data-ref.c	2 Sep 2004 15:58:36 -0000	1.1.2.37
--- tree-data-ref.c	2 Sep 2004 23:12:44 -0000
*************** build_classic_dist_vector (struct data_d
*** 1901,1908 ****
  	lca_nb = lca->num - first_loop;
  	while (lca->depth != 0)
  	  {
! 	    if (lca_nb < 0 || lca_nb >= nb_loops)
  	      abort ();
  	    if (init_v[lca_nb] == 0)
  	      dist_v[lca_nb] = 1;
  	    lca = lca->outer;
--- 1901,1914 ----
  	lca_nb = lca->num - first_loop;
  	while (lca->depth != 0)
  	  {
! 	    /* If we're considering just a sub-nest, then don't record
! 	       any information on the outer loops.  */
! 	    if (lca_nb < 0)
! 	      break;
! 
! 	    if (lca_nb >= nb_loops)
  	      abort ();
+ 
  	    if (init_v[lca_nb] == 0)
  	      dist_v[lca_nb] = 1;
  	    lca = lca->outer;
*************** build_classic_dir_vector (struct data_de
*** 2064,2071 ****
  	lca_nb = lca->num - first_loop;
  	while (lca->depth != 0)
  	  {
! 	    if (lca_nb < 0 || lca_nb >= nb_loops)
  	      abort ();
  	    if (init_v[lca_nb] == 0)
  	      dir_v[lca_nb] = dir_positive;
  	    lca = lca->outer;
--- 2070,2083 ----
  	lca_nb = lca->num - first_loop;
  	while (lca->depth != 0)
  	  {
! 	    /* If we're considering just a sub-nest, then don't record
! 	       any information on the outer loops.  */
! 	    if (lca_nb < 0)
! 	      break;
! 
! 	    if( lca_nb >= nb_loops)
  	      abort ();
+ 
  	    if (init_v[lca_nb] == 0)
  	      dir_v[lca_nb] = dir_positive;
  	    lca = lca->outer;



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