https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66375

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|law at gcc dot gnu.org             |spop at gcc dot gnu.org

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Sebastian - it seems that we have to somehow tell the analysis phase that we
are analyzing an evolution, not just an initial value.  Like instead of

              /* Match an assignment under the form:
                 "a = b + ...".  */
              res = follow_ssa_edge
                (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                 evolution_of_loop, limit);
              if (res == t_true)
                *evolution_of_loop = add_to_evolution
                  (loop->num, chrec_convert (type, *evolution_of_loop,
                                             at_stmt),
                   code, rhs1, at_stmt);

doing the add_to_evolution first and only then following the SSA edge.
That seems to kind-of work, though the debug output is strange:

(analyze_scalar_evolution
  (loop_nb = 1)
  (scalar = c_1)
(get_scalar_evolution
  (scalar = c_1)
  (scalar_evolution = ))
(analyze_initial_condition
  (loop_phi_node =
c_1 = PHI <0(2), c_7(3)>
)
  (init_cond = 0))
(analyze_evolution_in_loop
  (loop_phi_node = c_1 = PHI <0(2), c_7(3)>
)
(add_to_evolution
  (loop_nb = 1)
  (chrec_before = 0)
  (to_add = -11)
  (res = {0, +, -11}_1))
... computing niter, from chrec_convert stuff I guess
  (evolution_function = (int) (signed char) {0, +, 245}_1))

(that 245 looks wrong)

but at least the scalar evolution ends up (correctly) as being not know...

That is with

Index: tree-scalar-evolution.c
===================================================================
--- tree-scalar-evolution.c     (revision 224013)
+++ tree-scalar-evolution.c     (working copy)
@@ -991,15 +991,15 @@ follow_ssa_edge_binary (struct loop *loo
            {
              /* Match an assignment under the form:
                 "a = b + ...".  */
+             *evolution_of_loop = add_to_evolution
+                 (loop->num, chrec_convert (type, *evolution_of_loop,
+                                            at_stmt),
+                  code, rhs1, at_stmt);
              res = follow_ssa_edge
                (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                 evolution_of_loop, limit);
              if (res == t_true)
-               *evolution_of_loop = add_to_evolution
-                 (loop->num, chrec_convert (type, *evolution_of_loop,
-                                            at_stmt),
-                  code, rhs1, at_stmt);
-
+               ;
              else if (res == t_dont_know)
                *evolution_of_loop = chrec_dont_know;
            }

but as said, I don't think this is correct ...?  (just thrown it to testing)

Reply via email to