This fixes PR52701, we need to unconditionally remember the evolution
as irrelevant PHIs (apart from their final value) are not detected
as induction with variable step.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2012-03-26  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/52701
        * tree-vect-loop.c (vect_analyze_scalar_cycles_1): Always
        compute and set the evolution part of PHI nodes.

        * gfortran.dg/pr52701.f90: New testcase.

Index: gcc/tree-vect-loop.c
===================================================================
*** gcc/tree-vect-loop.c        (revision 185792)
--- gcc/tree-vect-loop.c        (working copy)
*************** vect_analyze_scalar_cycles_1 (loop_vec_i
*** 565,575 ****
        /* Analyze the evolution function.  */
        access_fn = analyze_scalar_evolution (loop, def);
        if (access_fn)
-       STRIP_NOPS (access_fn);
-       if (access_fn && vect_print_dump_info (REPORT_DETAILS))
        {
!         fprintf (vect_dump, "Access function of PHI: ");
!         print_generic_expr (vect_dump, access_fn, TDF_SLIM);
        }
  
        if (!access_fn
--- 565,579 ----
        /* Analyze the evolution function.  */
        access_fn = analyze_scalar_evolution (loop, def);
        if (access_fn)
        {
!         STRIP_NOPS (access_fn);
!         if (vect_print_dump_info (REPORT_DETAILS))
!           {
!             fprintf (vect_dump, "Access function of PHI: ");
!             print_generic_expr (vect_dump, access_fn, TDF_SLIM);
!           }
!         STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
!           = evolution_part_in_loop_num (access_fn, loop->num);
        }
  
        if (!access_fn
*************** vect_analyze_scalar_cycles_1 (loop_vec_i
*** 579,586 ****
          continue;
        }
  
-       STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
-       = evolution_part_in_loop_num (access_fn, loop->num);
        gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) != 
NULL_TREE);
  
        if (vect_print_dump_info (REPORT_DETAILS))
--- 583,588 ----
Index: gcc/testsuite/gfortran.dg/pr52701.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr52701.f90       (revision 0)
--- gcc/testsuite/gfortran.dg/pr52701.f90       (revision 0)
***************
*** 0 ****
--- 1,20 ----
+ ! { dg-do compile }
+ ! { dg-options "-O3" }
+ function pr52701 (x, z, e, f, g, l)
+   integer a, b, c, d, e, f, g, i, j, l, pr52701
+   double precision x(e), z(e*e)
+   do i = l, f
+     do j = l, i
+       d = 0
+       do a = 1, g
+         c = a - g
+         do b = 1, g
+           d = d + 1
+           c = c + g
+           z(d) = z(d) / (x(i) + x(j) - x(f + a) - x(f + b))
+         end do
+       end do
+     end do
+   end do
+   pr52701 = c
+ end

Reply via email to