loop.c (loop_givs_reduce): Avoid miscompilation of loops entered at bottom.
authorDale Johannesen <dalej@apple.com>
Wed, 16 Jun 2004 17:13:34 +0000 (17:13 +0000)
committerDale Johannesen <dalej@gcc.gnu.org>
Wed, 16 Jun 2004 17:13:34 +0000 (17:13 +0000)
2004-06-16  Dale Johannesen  <dalej@apple.com>

        * loop.c (loop_givs_reduce): Avoid miscompilation of
        loops entered at bottom.

From-SVN: r83248

gcc/ChangeLog
gcc/loop.c

index b4c81e70acd116f8a4a23c98d7f3720cc6f6d5ef..8b1ca6fb1eff4af3e50adc20b46fda50f02697e8 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-16  Dale Johannesen  <dalej@apple.com>
+
+        * loop.c (loop_givs_reduce): Avoid miscompilation of
+        loops entered at bottom.
+
 2004-06-16  J"orn Rennecke <joern.rennecke@superh.com>
 
        * cfglayout.c (fixup_reorder_chain): Handle case where the
index fd0c0d6435447f02b5dc6170fe37c709b8671dea..aafb18c02f9fe3170c47cc2d8b85af9d45c5cac9 100644 (file)
@@ -4699,13 +4699,24 @@ loop_givs_reduce (struct loop *loop, struct iv_class *bl)
             this is an address giv, then try to put the increment
             immediately after its use, so that flow can create an
             auto-increment addressing mode.  */
+         /* Don't do this for loops entered at the bottom, to avoid
+            this invalid transformation:
+               jmp L;          ->          jmp L;
+            TOP:                       TOP:
+               use giv                     use giv
+            L:                             inc giv
+               inc biv                 L:
+               test biv                    test giv
+               cbr TOP                     cbr TOP
+         */
          if (v->giv_type == DEST_ADDR && bl->biv_count == 1
              && bl->biv->always_executed && ! bl->biv->maybe_multiple
              /* We don't handle reversed biv's because bl->biv->insn
                 does not have a valid INSN_LUID.  */
              && ! bl->reversed
              && v->always_executed && ! v->maybe_multiple
-             && INSN_UID (v->insn) < max_uid_for_loop)
+             && INSN_UID (v->insn) < max_uid_for_loop
+             && !loop->top)    
            {
              /* If other giv's have been combined with this one, then
                 this will work only if all uses of the other giv's occur