On February 13, 2015 8:48:25 PM CET, Jakub Jelinek <ja...@redhat.com> wrote:
>Hi!
>
>With LTO and -O0 initial compilation, -O1 linking we at some point used
>to
>add stmts normal after a PHI, which is invalid.
>This patch fixes that by inserting after labels instead.
>No testcase provided, as the issue is latent anyway and I don't know
>how to
>write lto testcases that use different options initially from linking
>options.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Thanks,
Richard.

>2015-02-13  Jakub Jelinek  <ja...@redhat.com>
>
>       PR tree-optimization/62209
>       * tree-ssa-reassoc.c (update_range_test): If stmt is a PHI and
>       op == range->exp, insert seq and gimplified code after labels
>       instead of after the phi.
>
>--- gcc/tree-ssa-reassoc.c.jj  2015-02-13 15:02:03.000000000 +0100
>+++ gcc/tree-ssa-reassoc.c     2015-02-13 16:52:05.113232491 +0100
>@@ -2160,10 +2160,18 @@ update_range_test (struct range_entry *r
> 
>   tem = fold_convert_loc (loc, optype, tem);
>   gsi = gsi_for_stmt (stmt);
>+  unsigned int uid = gimple_uid (stmt);
>   /* In rare cases range->exp can be equal to lhs of stmt.
>      In that case we have to insert after the stmt rather then before
>-     it.  */
>-  if (op == range->exp)
>+     it.  If stmt is a PHI, insert it at the start of the basic block.
> */
>+  if (op != range->exp)
>+    {
>+      gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
>+      tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE,
>true,
>+                                    GSI_SAME_STMT);
>+      gsi_prev (&gsi);
>+    }
>+  else if (gimple_code (stmt) != GIMPLE_PHI)
>     {
>       gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
>     tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, false,
>@@ -2171,16 +2179,32 @@ update_range_test (struct range_entry *r
>     }
>   else
>     {
>+      gsi = gsi_after_labels (gimple_bb (stmt));
>+      if (!gsi_end_p (gsi))
>+      uid = gimple_uid (gsi_stmt (gsi));
>+      else
>+      {
>+        gsi = gsi_start_bb (gimple_bb (stmt));
>+        uid = 1;
>+        while (!gsi_end_p (gsi))
>+          {
>+            uid = gimple_uid (gsi_stmt (gsi));
>+            gsi_next (&gsi);
>+          }
>+      }
>       gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
>      tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
>                                     GSI_SAME_STMT);
>-      gsi_prev (&gsi);
>+      if (gsi_end_p (gsi))
>+      gsi = gsi_last_bb (gimple_bb (stmt));
>+      else
>+      gsi_prev (&gsi);
>     }
>   for (; !gsi_end_p (gsi); gsi_prev (&gsi))
>     if (gimple_uid (gsi_stmt (gsi)))
>       break;
>     else
>-      gimple_set_uid (gsi_stmt (gsi), gimple_uid (stmt));
>+      gimple_set_uid (gsi_stmt (gsi), uid);
> 
>   oe->op = tem;
>   range->exp = exp;
>
>       Jakub


Reply via email to