]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/94964 - avoid EH loop entry with CP_SIMPLE_PREHEADERS
authorRichard Biener <rguenther@suse.de>
Wed, 6 May 2020 08:23:15 +0000 (10:23 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 11 Sep 2020 10:37:38 +0000 (12:37 +0200)
Loop optimizers expect to be able to insert on the preheader
edge w/o splitting it thus avoid ending up with a preheader
that enters the loop via an EH edge (or an abnormal edge).

2020-05-06  Richard Biener  <rguenther@suse.de>

PR middle-end/94964
* cfgloopmanip.c (create_preheader): Require non-complex
preheader edge for CP_SIMPLE_PREHEADERS.

(cherry picked from commit 6fc00b41e764219e2c88d8892d7c701c0d292a17)

gcc/cfgloopmanip.c

index bfee48ed8ccdea326d56bf252df03f0c2b814fb4..3980a9b45f580b6f2f584c782368d8243d1db4df 100644 (file)
@@ -1505,9 +1505,10 @@ create_preheader (struct loop *loop, int flags)
       else
         {
           /* If we want simple preheaders, also force the preheader to have
-             just a single successor.  */
+            just a single successor and a normal edge.  */
           if ((flags & CP_SIMPLE_PREHEADERS)
-              && !single_succ_p (single_entry->src))
+             && ((single_entry->flags & EDGE_COMPLEX)
+                 || !single_succ_p (single_entry->src)))
             need_forwarder_block = true;
           /* If we want fallthru preheaders, also create forwarder block when
              preheader ends with a jump or has predecessors from loop.  */