]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2012-12-20 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Dec 2012 12:45:48 +0000 (12:45 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Dec 2012 12:45:48 +0000 (12:45 +0000)
PR middle-end/55740
* cfghooks.c (merge_blocks): Properly handle merging of
two loop headers.

* g++.dg/torture/pr55740.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194633 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfghooks.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr55740.C [new file with mode: 0644]

index 6d385605b629ed2e9d8ec181de2a88fc386784eb..01ed19b182580505bd63733949c0e6a42777ce59 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-20  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/55740
+       * cfghooks.c (merge_blocks): Properly handle merging of
+       two loop headers.
+
 2012-12-20  Roland Stigge  <stigge@debian.org>
            Matthias Klose  <doko@ubuntu.com>
 
index f0957316062540306122bc5d0f13c5c30182ea5d..b729ae00504e76fb3e5f871b2cd89010423ab7bc 100644 (file)
@@ -724,11 +724,23 @@ merge_blocks (basic_block a, basic_block b)
 
   cfg_hooks->merge_blocks (a, b);
 
-  /* If we merge a loop header into its predecessor, update the loop
-     structure.  */
   if (current_loops != NULL)
     {
-      if (b->loop_father->header == b)
+      /* If the block we merge into is a loop header do nothing unless ... */
+      if (a->loop_father->header == a)
+       {
+         /* ... we merge two loop headers, in which case we kill
+            the inner loop.  */
+         if (b->loop_father->header == b)
+           {
+             b->loop_father->header = NULL;
+             b->loop_father->latch = NULL;
+             loops_state_set (LOOPS_NEED_FIXUP);
+           }
+       }
+      /* If we merge a loop header into its predecessor, update the loop
+        structure.  */
+      else if (b->loop_father->header == b)
        {
          remove_bb_from_loops (a);
          add_bb_to_loop  (a, b->loop_father);
index 1b7c851df3838ce1741a44975ad5f39f385714af..1f401cd7ac7749874c93c9c89f2918a4ab756862 100644 (file)
@@ -1,3 +1,8 @@
+2012-12-20  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/55740
+       * g++.dg/torture/pr55740.C: New testcase.
+
 2012-12-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/55619
diff --git a/gcc/testsuite/g++.dg/torture/pr55740.C b/gcc/testsuite/g++.dg/torture/pr55740.C
new file mode 100644 (file)
index 0000000..cdd8425
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile }
+
+static bool st_IsPathDelimiter( char c ) { return c == '/'; }
+bool IsValidPath( char const * filename )
+{
+  if ( !filename || filename[0] == 0 )     
+    return false;
+  char const * run = filename;
+  while ( run && *run )       
+    {
+      if ( run[0] == '.' )   
+       if ( run[1] != '.' || ( !st_IsPathDelimiter( run[2] ) && run[2] != 0 ) )   
+         return false;   
+      while ( *run && !st_IsPathDelimiter( *run ) )
+       ++run;
+      if ( *run ) 
+       ++run;
+    }
+}