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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2016-08-02
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that for some odd reason creating the preheader causes the PHI to appar.
Fixing that would be appreciated - it's the make_forwarder_block CFG hook
that causes this.  Not sure why create_preheader doesn't special-case the
single_entry != NULL case by simply splitting the edge.

The following fixes the testcase:

Index: cfgloopmanip.c
===================================================================
--- cfgloopmanip.c      (revision 238938)
+++ cfgloopmanip.c      (working copy)
@@ -1497,7 +1497,7 @@ has_preds_from_loop (basic_block block,
 basic_block
 create_preheader (struct loop *loop, int flags)
 {
-  edge e, fallthru;
+  edge e;
   basic_block dummy;
   int nentry = 0;
   bool irred = false;
@@ -1544,9 +1544,14 @@ create_preheader (struct loop *loop, int

   mfb_kj_edge = loop_latch_edge (loop);
   latch_edge_was_fallthru = (mfb_kj_edge->flags & EDGE_FALLTHRU) != 0;
-  fallthru = make_forwarder_block (loop->header, mfb_keep_just, NULL);
-  dummy = fallthru->src;
-  loop->header = fallthru->dest;
+  if (single_entry)
+    dummy = split_edge (single_entry);
+  else
+    {
+      edge fallthru = make_forwarder_block (loop->header, mfb_keep_just,
NULL);
+      dummy = fallthru->src;
+      loop->header = fallthru->dest;
+    }

   /* Try to be clever in placing the newly created preheader.  The idea is to
      avoid breaking any "fallthruness" relationship between blocks.

Reply via email to