This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Update for cprop patch
- To: Bernd Schmidt <bernds at cygnus dot co dot uk>
- Subject: Re: Update for cprop patch
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 24 Aug 1999 22:23:24 -0600
- cc: egcs-patches at egcs dot cygnus dot com
- Reply-To: law at cygnus dot com
Opps. Hit the send button rather than the "attach file button". Here
the cprop improvement patch I installed for you
* gcse.c (find_avail_set): Follow chains of register-register copies.
Use oprs_not_set_p to guarantee that the returned value can be
substituted.
(cprop_insn): Don't verify the return value of find_avail_set with
oprs_not_set_p.
Index: gcse.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/gcse.c,v
retrieving revision 1.43
diff -c -3 -p -r1.43 gcse.c
*** gcse.c 1999/08/25 03:30:45 1.43
--- gcse.c 1999/08/25 04:20:40
*************** find_avail_set (regno, insn)
*** 3656,3671 ****
int regno;
rtx insn;
{
! struct expr *set = lookup_set (regno, NULL_RTX);
! while (set)
! {
! if (TEST_BIT (cprop_avin[BLOCK_NUM (insn)], set->bitmap_index))
break;
- set = next_set (regno, set);
- }
! return set;
}
/* Subroutine of cprop_insn that tries to propagate constants into
--- 3656,3720 ----
int regno;
rtx insn;
{
! /* SET1 contains the last set found that can be returned to the caller for
! use in a substitution. */
! struct expr *set1 = 0;
!
! /* Loops are not possible here. To get a loop we would need two sets
! available at the start of the block containing INSN. ie we would
! need two sets like this available at the start of the block:
!
! (set (reg X) (reg Y))
! (set (reg Y) (reg X))
!
! This can not happen since the set of (reg Y) would have killed the
! set of (reg X) making it unavailable at the start of this block. */
! while (1)
! {
! rtx src;
! struct expr *set = lookup_set (regno, NULL_RTX);
!
! /* Find a set that is available at the start of the block
! which contains INSN. */
! while (set)
! {
! if (TEST_BIT (cprop_avin[BLOCK_NUM (insn)], set->bitmap_index))
! break;
! set = next_set (regno, set);
! }
! /* If no available set was found we've reached the end of the
! (possibly empty) copy chain. */
! if (set == 0)
! break;
!
! if (GET_CODE (set->expr) != SET)
! abort ();
!
! src = SET_SRC (set->expr);
!
! /* We know the set is available.
! Now check that SRC is ANTLOC (i.e. none of the source operands
! have changed since the start of the block).
!
! If the source operand changed, we may still use it for the next
! iteration of this loop, but we may not use it for substitutions. */
! if (CONSTANT_P (src) || oprs_not_set_p (src, insn))
! set1 = set;
!
! /* If the source of the set is anything except a register, then
! we have reached the end of the copy chain. */
! if (GET_CODE (src) != REG)
break;
! /* Follow the copy chain, ie start another iteration of the loop
! and see if we have an available copy into SRC. */
! regno = REGNO (src);
! }
!
! /* SET1 holds the last set that was available and anticipatable at
! INSN. */
! return set1;
}
/* Subroutine of cprop_insn that tries to propagate constants into
*************** cprop_insn (insn, alter_jumps)
*** 3875,3901 ****
&& REGNO (src) >= FIRST_PSEUDO_REGISTER
&& REGNO (src) != regno)
{
! /* We know the set is available.
! Now check that SET_SRC is ANTLOC (i.e. none of the source operands
! have changed since the start of the block). */
! if (oprs_not_set_p (src, insn))
{
! if (try_replace_reg (reg_used->reg_rtx, src, insn))
{
! changed = 1;
! copy_prop_count++;
! if (gcse_file != NULL)
! {
! fprintf (gcse_file, "COPY-PROP: Replacing reg %d in insn %d with reg %d\n",
! regno, INSN_UID (insn), REGNO (src));
! }
!
! /* The original insn setting reg_used may or may not now be
! deletable. We leave the deletion to flow. */
! /* FIXME: If it turns out that the insn isn't deletable,
! then we may have unnecessarily extended register lifetimes
! and made things worse. */
}
}
}
}
--- 3924,3944 ----
&& REGNO (src) >= FIRST_PSEUDO_REGISTER
&& REGNO (src) != regno)
{
! if (try_replace_reg (reg_used->reg_rtx, src, insn))
{
! changed = 1;
! copy_prop_count++;
! if (gcse_file != NULL)
{
! fprintf (gcse_file, "COPY-PROP: Replacing reg %d in insn %d with reg %d\n",
! regno, INSN_UID (insn), REGNO (src));
}
+
+ /* The original insn setting reg_used may or may not now be
+ deletable. We leave the deletion to flow. */
+ /* FIXME: If it turns out that the insn isn't deletable,
+ then we may have unnecessarily extended register lifetimes
+ and made things worse. */
}
}
}