Fix buglet in previous mechanical loop.c change

Jeffrey A Law law@redhat.com
Thu Jul 15 19:31:00 GMT 2004


The recent change to use various predicates instead of explicitly
testing for suitable rtx codes had a minor flaw.  Consider this
change fragment from loop.c:

***************
*** 5482,5495 ****
      }
   
    /* Look for givs which are memory addresses.  */
!   if (GET_CODE (p) == INSN)
      find_mem_givs (loop, PATTERN (p), p, not_every_iteration,
                   maybe_multiple);
   
    /* Update the status of whether giv can derive other givs.  This can
       change when we pass a label or an insn that updates a biv.  */
!   if (GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
!       || GET_CODE (p) == CODE_LABEL)
      update_giv_derive (loop, p);
    return p;
  }
--- 5479,5491 ----
      }
   
    /* Look for givs which are memory addresses.  */
!   if (NONJUMP_INSN_P (p))
      find_mem_givs (loop, PATTERN (p), p, not_every_iteration,
                   maybe_multiple);
   
    /* Update the status of whether giv can derive other givs.  This can
       change when we pass a label or an insn that updates a biv.  */
!   if (INSN_P (p))
      update_giv_derive (loop, p);
    return p;
  }


In particular note that we no longer call update_giv_derive if P is a
CODE_LABEL.

This can cause the loop optimizer to incorrectly reduce a GIV when it's
BIV is conditionally incremented.

I've been unable to trip this with unmodified sources, but it caused a
bootstrap failure (hang building libgcc with the stage2 compiler) with
a hacked compiler I'm using to evaluate the jump threading code.

This patch restores the previous behavior.

Bootstrapped on i686-pc-linux-gnu.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ZZZ
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040715/dcecc5e4/attachment.bin>


More information about the Gcc-patches mailing list