The UID of a newly generated statement in build_and_add_sum is set to
that of an adjacent statement in the BB. This is a problem in one case
where the BB is empty. This fix sets the UID to be 1 if the BB is
empty. Bootstraps and no test regressions on x86_64 . OK for trunk?

Thanks,
Easwaran

-----------

2013-05-19   Easwaran Raman  <era...@google.com>

        PR tree-optimization/57322
        * (build_and_add_sum): If a BB is empty, set the UID of the statement
        added to the BB to be 1.

Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c      (revision 199048)
+++ gcc/tree-ssa-reassoc.c      (working copy)
@@ -1165,8 +1165,12 @@ build_and_add_sum (tree type, tree op1, tree op2,
   if ((!op1def || gimple_nop_p (op1def))
       && (!op2def || gimple_nop_p (op2def)))
     {
+      gimple first_stmt;
+      unsigned uid;
       gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
-      gimple_set_uid (sum, gimple_uid (gsi_stmt (gsi)));
+      first_stmt = gsi_stmt (gsi);
+      uid = first_stmt ? gimple_uid (first_stmt) : 1;
+      gimple_set_uid (sum, uid);
       gsi_insert_before (&gsi, sum, GSI_NEW_STMT);
     }
   else if ((!op1def || gimple_nop_p (op1def))

Reply via email to