This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Avoid most of calls to side_effects_p
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at redhat dot com
- Date: Wed, 12 Mar 2003 14:53:49 +0100
- Subject: Avoid most of calls to side_effects_p
Hi,
this avoids about 70% of side_effects_p calls that is about the most commonly called
function in GCC. In the first hunk, the call is
useless as it is checked later when instruction is being considered for
removal. In the second case it is cheaper to first match the operands and then
check just one of them.
Similary I killed use of find_reg_note in find_reg_equal_equiv_note.
Bootstrapped/regtested i386
Wed Mar 12 14:47:37 CET 2003 Jan Hubicka <jh at sue dot cz>
* cse.c (count_reg_usage): Do not check side_effects_p.
* (set_noop_p): Check side_effects_p only when set looks
like noop.
(find_reg_equal_equiv_note): Do not use find_reg_note.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.255
diff -c -3 -p -r1.255 cse.c
*** cse.c 26 Feb 2003 10:48:34 -0000 1.255
--- cse.c 12 Mar 2003 13:45:55 -0000
*************** count_reg_usage (x, counts, dest, incr)
*** 7494,7508 ****
/* Unless we are setting a REG, count everything in SET_DEST. */
if (GET_CODE (SET_DEST (x)) != REG)
count_reg_usage (SET_DEST (x), counts, NULL_RTX, incr);
-
- /* If SRC has side-effects, then we can't delete this insn, so the
- usage of SET_DEST inside SRC counts.
-
- ??? Strictly-speaking, we might be preserving this insn
- because some other SET has side-effects, but that's hard
- to do and can't happen now. */
count_reg_usage (SET_SRC (x), counts,
! side_effects_p (SET_SRC (x)) ? NULL_RTX : SET_DEST (x),
incr);
return;
--- 7494,7501 ----
/* Unless we are setting a REG, count everything in SET_DEST. */
if (GET_CODE (SET_DEST (x)) != REG)
count_reg_usage (SET_DEST (x), counts, NULL_RTX, incr);
count_reg_usage (SET_SRC (x), counts,
! SET_DEST (x),
incr);
return;
Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.148
diff -c -3 -p -r1.148 rtlanal.c
*** rtlanal.c 10 Mar 2003 17:23:44 -0000 1.148
--- rtlanal.c 12 Mar 2003 13:45:55 -0000
*************** set_noop_p (set)
*** 1327,1345 ****
rtx src = SET_SRC (set);
rtx dst = SET_DEST (set);
- if (side_effects_p (src) || side_effects_p (dst))
- return 0;
-
- if (GET_CODE (dst) == MEM && GET_CODE (src) == MEM)
- return rtx_equal_p (dst, src);
-
if (dst == pc_rtx && src == pc_rtx)
return 1;
if (GET_CODE (dst) == SIGN_EXTRACT
|| GET_CODE (dst) == ZERO_EXTRACT)
return rtx_equal_p (XEXP (dst, 0), src)
! && ! BYTES_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx;
if (GET_CODE (dst) == STRICT_LOW_PART)
dst = XEXP (dst, 0);
--- 1327,1343 ----
rtx src = SET_SRC (set);
rtx dst = SET_DEST (set);
if (dst == pc_rtx && src == pc_rtx)
return 1;
+ if (GET_CODE (dst) == MEM && GET_CODE (src) == MEM)
+ return rtx_equal_p (dst, src) && !side_effects_p (dst);
+
if (GET_CODE (dst) == SIGN_EXTRACT
|| GET_CODE (dst) == ZERO_EXTRACT)
return rtx_equal_p (XEXP (dst, 0), src)
! && ! BYTES_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx
! && !side_effects_p (src);
if (GET_CODE (dst) == STRICT_LOW_PART)
dst = XEXP (dst, 0);
*************** rtx
*** 2018,2031 ****
find_reg_equal_equiv_note (insn)
rtx insn;
{
! rtx note;
! if (single_set (insn) == 0)
return 0;
! else if ((note = find_reg_note (insn, REG_EQUIV, NULL_RTX)) != 0)
! return note;
! else
! return find_reg_note (insn, REG_EQUAL, NULL_RTX);
}
/* Return true if DATUM, or any overlap of DATUM, of kind CODE is found
--- 2016,2034 ----
find_reg_equal_equiv_note (insn)
rtx insn;
{
! rtx link;
! if (!INSN_P (insn))
return 0;
! for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
! if (REG_NOTE_KIND (link) == REG_EQUAL
! || REG_NOTE_KIND (link) == REG_EQUIV)
! {
! if (single_set (insn) == 0)
! return 0;
! return link;
! }
! return NULL;
}
/* Return true if DATUM, or any overlap of DATUM, of kind CODE is found