This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] reload1.c: Detect and utilize implicit sets in move2add.(take 2)
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: rth at redhat dot com
- Date: Sun, 27 Apr 2003 15:38:00 -0400 (EDT)
- Subject: [patch] reload1.c: Detect and utilize implicit sets in move2add.(take 2)
Hi,
Attached is a patch to detect implicit sets in move2add and treat such
sets identically to explicit sets. This patch is a revised version of
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00733.html
This version addresses the bootstrap failure on
alphaev67-unknown-linux-gnu that occurred with my previous patch. The
reason for the failure was exactly the same as the one Roger Sayle
faced when implementing implicit set detection in gcse.c. See
http://gcc.gnu.org/ml/gcc-patches/2003-02/msg00468.html
Bootstrapped on alphaev67-unknown-linux-gnu. Tested on h8300 port.
OK to apply?
Kazu Hirata
2003-04-27 Kazu Hirata <kazu at cs dot umass dot edu>
* gcse.c (fis_get_condition): Make it a global function.
* reload1.c (reload_cse_move2add): Detect implicit sets.
* rtl.h: Add a prototype for fis_get_condition.
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.248
diff -u -r1.248 gcse.c
--- gcse.c 25 Apr 2003 00:58:27 -0000 1.248
+++ gcse.c 27 Apr 2003 05:29:01 -0000
@@ -611,7 +611,6 @@
static void canon_list_insert PARAMS ((rtx, rtx, void *));
static int cprop_insn PARAMS ((rtx, int));
static int cprop PARAMS ((int));
-static rtx fis_get_condition PARAMS ((rtx));
static void find_implicit_sets PARAMS ((void));
static int one_cprop_pass PARAMS ((int, int, int));
static bool constprop_register PARAMS ((rtx, rtx, rtx, int));
@@ -4576,7 +4575,7 @@
recording the value of *every* register scaned by canonicalize_condition,
but this would require some code reorganization. */
-static rtx
+rtx
fis_get_condition (jump)
rtx jump;
{
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.390
diff -u -r1.390 reload1.c
--- reload1.c 18 Apr 2003 20:30:24 -0000 1.390
+++ reload1.c 27 Apr 2003 05:29:06 -0000
@@ -9288,6 +9288,26 @@
}
}
note_stores (PATTERN (insn), move2add_note_store, NULL);
+
+ /* If INSN is a conditional branch, we try to extract an
+ implicit set out of it. */
+ if (any_condjump_p (insn) && onlyjump_p (insn))
+ {
+ rtx cnd = fis_get_condition (insn);
+
+ if (cnd != NULL_RTX
+ && GET_CODE (cnd) == NE
+ && GET_CODE (XEXP (cnd, 0)) == REG
+ && SCALAR_INT_MODE_P (GET_MODE (XEXP (cnd, 0)))
+ && HARD_REGNO_NREGS (REGNO (XEXP (cnd, 0)), GET_MODE (XEXP (cnd, 0))) == 1
+ && GET_CODE (XEXP (cnd, 1)) == CONST_INT)
+ {
+ rtx implicit_set =
+ gen_rtx_SET (VOIDmode, XEXP (cnd, 0), XEXP (cnd, 1));
+ move2add_note_store (SET_DEST (implicit_set), implicit_set, 0);
+ }
+ }
+
/* If this is a CALL_INSN, all call used registers are stored with
unknown values. */
if (GET_CODE (insn) == CALL_INSN)
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.400
diff -u -r1.400 rtl.h
--- rtl.h 22 Apr 2003 23:17:44 -0000 1.400
+++ rtl.h 27 Apr 2003 05:29:08 -0000
@@ -2157,6 +2157,7 @@
/* In gcse.c */
extern bool can_copy_p PARAMS ((enum machine_mode));
+extern rtx fis_get_condition PARAMS ((rtx));
#ifdef BUFSIZ
extern int gcse_main PARAMS ((rtx, FILE *));
extern int bypass_jumps PARAMS ((FILE *));