loop.c (check_dbra_loop): When reversing a loop...
authorBernd Schmidt <bernds@cygnus.co.uk>
Fri, 9 Jul 1999 03:34:26 +0000 (03:34 +0000)
committerBernd Schmidt <crux@gcc.gnu.org>
Fri, 9 Jul 1999 03:34:26 +0000 (03:34 +0000)
* loop.c (check_dbra_loop): When reversing a loop, delete all
REG_EQUAL notes referencing the reversed biv except those which are
for a giv based on it.

From-SVN: r28043

gcc/ChangeLog
gcc/loop.c

index 7703a241b469ba0ba05be6efe075ef5010e95c21..4632ffc58384dac8299407ada0420ddccc6c48c4 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jul  9 10:48:28 1999  Bernd Schmidt  <bernds@cygnus.co.uk>
+
+       * loop.c (check_dbra_loop): When reversing a loop, delete all
+       REG_EQUAL notes referencing the reversed biv except those which are
+       for a giv based on it.
+
 Fri Jul  9 03:51:52 1999  Jeffrey A Law  (law@cygnus.com)
 
        * version.c: Drop "gcc-" prefix from version #.
index ef64fd08be73e89f582766b3e69e3ac12290c8bd..db50a1862e56a824b7ef3a76ce7d23c58933a307 100644 (file)
@@ -8107,6 +8107,40 @@ check_dbra_loop (loop_end, insn_count, loop_start, loop_info)
                  bl->nonneg = 1;
                }
 
+             /* No insn may reference both the reversed and another biv or it
+                will fail (see comment near the top of the loop reversal
+                code).
+                Earlier on, we have verified that the biv has no use except
+                counting, or it is the only biv in this function.
+                However, the code that computes no_use_except_counting does
+                not verify reg notes.  It's possible to have an insn that
+                references another biv, and has a REG_EQUAL note with an
+                expression based on the reversed biv.  To avoid this case,
+                remove all REG_EQUAL notes based on the reversed biv
+                here.  */
+             for (p = loop_start; p != loop_end; p = NEXT_INSN (p))
+               if (GET_RTX_CLASS (GET_CODE (p)) == 'i')
+                 {
+                   rtx *pnote;
+                   rtx set = single_set (p);
+                   /* If this is a set of a GIV based on the reversed biv, any
+                      REG_EQUAL notes should still be correct.  */
+                   if (! set
+                       || GET_CODE (SET_DEST (set)) != REG
+                       || REGNO (SET_DEST (set)) >= reg_iv_type->num_elements
+                       || REG_IV_TYPE (REGNO (SET_DEST (set))) != GENERAL_INDUCT
+                       || REG_IV_INFO (REGNO (SET_DEST (set)))->src_reg != bl->biv->src_reg)
+                     for (pnote = &REG_NOTES (p); *pnote;)
+                       {
+                         if (REG_NOTE_KIND (*pnote) == REG_EQUAL
+                             && reg_mentioned_p (regno_reg_rtx[bl->regno],
+                                                 XEXP (*pnote, 0)))
+                           *pnote = XEXP (*pnote, 1);
+                         else
+                           pnote = &XEXP (*pnote, 1);
+                       }
+                 }
+
              /* Mark that this biv has been reversed.  Each giv which depends
                 on this biv, and which is also live past the end of the loop
                 will have to be fixed up.  */