(recombine_givs): Don't use a giv that's likely to be dead to derive others.
authorJ"orn Rennecke <amylaar@cygnus.co.uk>
Tue, 2 Feb 1999 11:52:00 +0000 (11:52 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Tue, 2 Feb 1999 11:52:00 +0000 (11:52 +0000)
* (recombine_givs): Don't use a giv that's likely to be dead to
derive others.
* loop.c (recombine_givs): Fix test for lifetime overlaps / loop
wrap around when deriving givs.

From-SVN: r24967

gcc/ChangeLog
gcc/loop.c

index 89fd8ab40dc0ca8090d7c2e72fda2a66b9d8f6d7..cf302bc48f1ab7b77be94f40039699b891ef7602 100644 (file)
@@ -1,3 +1,11 @@
+Tue Feb  2 19:48:29 1999  J"orn Rennecke <amylaar@cygnus.co.uk>
+
+       * (recombine_givs): Don't use a giv that's likely to be dead to
+       derive others.
+
+       * loop.c (recombine_givs): Fix test for lifetime overlaps / loop
+       wrap around when deriving givs.
+
 Mon Feb  1 20:00:40 1999  Richard Henderson  <rth@cygnus.com>
 
        * recog.c (check_asm_operands): Treat indeterminate operand ok
index 4b03d367b46e53becfc46be04e736e4834dd536e..8323a273c6ab568ff8339b4899391c7ad6f75bc4 100644 (file)
@@ -7293,16 +7293,28 @@ recombine_givs (bl, loop_start, loop_end, unroll_p)
            continue;
          if (! last_giv)
            {
-             last_giv = v;
-             life_start = stats[i].start_luid;
-             life_end = stats[i].end_luid;
+             /* Don't use a giv that's likely to be dead to derive
+                others - that would be likely to keep that giv alive.  */
+             if (! v->maybe_dead || v->combined_with)
+               {
+                 last_giv = v;
+                 life_start = stats[i].start_luid;
+                 life_end = stats[i].end_luid;
+               }
              continue;
            }
          /* Use unsigned arithmetic to model loop wrap around.  */
          if (((unsigned) stats[i].start_luid - life_start
               >= (unsigned) life_end - life_start)
              && ((unsigned) stats[i].end_luid - life_start
-                 >= (unsigned) life_end - life_start)
+                 > (unsigned) life_end - life_start)
+             /*  Check that the giv insn we're about to use for deriving
+                 precedes all uses of that giv.  Note that initializing the
+                 derived giv would defeat the purpose of reducing register
+                 pressure.
+                 ??? We could arrange to move the insn.  */
+             && ((unsigned) stats[i].end_luid - INSN_LUID (loop_start)
+                  > (unsigned) stats[i].start_luid - INSN_LUID (loop_start))
              && rtx_equal_p (last_giv->mult_val, v->mult_val)
              /* ??? Could handle libcalls, but would need more logic.  */
              && ! find_reg_note (v->insn, REG_RETVAL, NULL_RTX)
@@ -7312,7 +7324,11 @@ recombine_givs (bl, loop_start, loop_end, unroll_p)
                 don't have this detailed control flow information.
                 N.B. since last_giv will be reduced, it is valid
                 anywhere in the loop, so we don't need to check the
-                validity of last_giv.  */
+                validity of last_giv.
+                We rely here on the fact that v->always_executed implies that
+                there is no jump to someplace else in the loop before the
+                giv insn, and hence any insn that is executed before the
+                giv insn in the loop will have a lower luid.  */
              && (v->always_executed || ! v->combined_with)
              && (sum = express_from (last_giv, v))
              /* Make sure we don't make the add more expensive.  ADD_COST