On Wed, May 15, 2013 at 02:58:22PM +0200, Richard Biener wrote:
> On Wed, May 15, 2013 at 2:07 PM, Marek Polacek <pola...@redhat.com> wrote:
> >           /* Replace the uses of the name.  */
> >           if (name != ev)
> > -           replace_uses_by (name, ev);
> > +           {
> > +             replace_uses_by (name, ev);
> > +             if (dump_file && (dump_flags & TDF_SCEV))
> 
> should be without dump_flags checking

Ok.

> > +               {
> > +                 fprintf (dump_file, "(replace_stmt \n  (");
> > +                 print_generic_expr (dump_file, name, 0);
> > +                 fprintf (dump_file, " with ");
> > +                 print_generic_expr (dump_file, ev, 0);
> > +                 fprintf (dump_file, ")\n) \n");
> 
> and no need to do it the LISP-y way ;)

Good, I didn't like it much anyway.

> I would have liked to see failed attempts as well, then with TDF_DETAILS.
> Failed attempts for the "real" final value replacement stuff (I'm not sure
> the constant propagation part is worth keeping ... how often does it trigger?)

Not much often: I've measured it and it happens only in ~150 testcases
from the whole c/c++/fortran testsuites.  So, like this?  Thanks,

It looks like:
not replacing:
  n_4 = PHI <n_3(4)>

and

final value replacement:
  n_4 = PHI <n_3(4)>
  with
  n_4 = _1 + _12;

2013-05-15  Marek Polacek  <pola...@redhat.com>

        * tree-scalar-evolution.c (scev_const_prop): Add more dumps.

--- gcc/tree-scalar-evolution.c.mp      2013-05-15 15:09:06.579122696 +0200
+++ gcc/tree-scalar-evolution.c 2013-05-15 16:32:11.569217537 +0200
@@ -3385,12 +3385,24 @@ scev_const_prop (void)
                 to be turned into n %= 45.  */
              || expression_expensive_p (def))
            {
+             if (dump_file && (dump_flags & TDF_DETAILS))
+               {
+                 fprintf (dump_file, "not replacing:\n  ");
+                 print_gimple_stmt (dump_file, phi, 0, 0);
+                 fprintf (dump_file, "\n");
+               }
              gsi_next (&psi);
              continue;
            }
 
          /* Eliminate the PHI node and replace it by a computation outside
             the loop.  */
+         if (dump_file)
+           {
+             fprintf (dump_file, "\nfinal value replacement:\n  ");
+             print_gimple_stmt (dump_file, phi, 0, 0);
+             fprintf (dump_file, "  with\n  ");
+           }
          def = unshare_expr (def);
          remove_phi_node (&psi, false);
 
@@ -3398,6 +3410,11 @@ scev_const_prop (void)
                                          true, GSI_SAME_STMT);
          ass = gimple_build_assign (rslt, def);
          gsi_insert_before (&bsi, ass, GSI_SAME_STMT);
+         if (dump_file)
+           {
+             print_gimple_stmt (dump_file, ass, 0, 0);
+             fprintf (dump_file, "\n");
+           }
        }
     }
   return 0;

        Marek

Reply via email to