loop.c (check_dbra_loop): The loop ending comparison value must be an invariant or...
authorJeffrey A Law <law@cygnus.com>
Fri, 28 Aug 1998 00:10:42 +0000 (00:10 +0000)
committerJeff Law <law@gcc.gnu.org>
Fri, 28 Aug 1998 00:10:42 +0000 (18:10 -0600)
        * loop.c (check_dbra_loop): The loop ending comparison value
        must be an invariant or we can not reverse the loop.

From-SVN: r22045

gcc/ChangeLog
gcc/loop.c

index 6db8ceaddffa0b140c7e2f03baec568e5e62c0ed..ae5ef3d301a239dcfbd7ec085b64827403e28f85 100644 (file)
@@ -1,5 +1,8 @@
 Thu Aug 27 20:10:46 1998  Jeffrey A Law  (law@cygnus.com)
 
+       * loop.c (check_dbra_loop): The loop ending comparison value
+       must be an invariant or we can not reverse the loop.
+
        * loop.c (scan_loop): Count down from max_reg_num - 1 to
        FIRST_PSEUDO_REGISTER to avoid calling max_reg_num each iteration
        of the loop.
index 3301f7d2f29149cd0c1bc93998690b24245fa518..cd257be9c352c09c31a5cea7638e44fc884fe959 100644 (file)
@@ -6904,6 +6904,15 @@ check_dbra_loop (loop_end, insn_count, loop_start)
              comparison_sign_mask
                = (unsigned HOST_WIDE_INT)1 << (comparison_const_width - 1);
 
+             /* If the comparison value is not a loop invariant, then we
+                can not reverse this loop.
+
+                ??? If the insns which initialize the comparison value as
+                a whole compute an invariant result, then we could move
+                them out of the loop and proceed with loop reversal.  */
+             if (!invariant_p (comparison_val))
+               return 0;
+
              if (GET_CODE (comparison_value) == CONST_INT)
                comparison_val = INTVAL (comparison_value);
              initial_value = bl->initial_value;