From 2dfa9a87f6860348995b47f2432f851e3ce4d6f2 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Mon, 15 Mar 1999 01:52:49 +0000 Subject: [PATCH] rtlanal.c (auto_inc_p): New function. * rtlanal.c (auto_inc_p): New function. * rtl.h (auto_inc_p): Prototype it. * reload1.c (add_auto_inc_notes): New function. (reload): Strip REG_INC notes and call add_auto_inc_notes for each insn to restore them correctly. From-SVN: r25774 --- gcc/ChangeLog | 8 ++++++++ gcc/reload1.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- gcc/rtl.h | 1 + gcc/rtlanal.c | 24 ++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ac346d163e9..cbf81e5dbb2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +Mon Mar 15 22:50:18 1999 Michael Hayes + + * rtlanal.c (auto_inc_p): New function. + * rtl.h (auto_inc_p): Prototype it. + * reload1.c (add_auto_inc_notes): New function. + (reload): Strip REG_INC notes and call add_auto_inc_notes + for each insn to restore them correctly. + 1999-03-15 Manfred Hollstein * fixinc/Makefile.in (procopen.o): List the actual diff --git a/gcc/reload1.c b/gcc/reload1.c index 440283195df..1e83d5fe4be 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -443,6 +443,9 @@ static void reload_combine_note_use PROTO((rtx *, rtx)); static void reload_combine_note_store PROTO((rtx, rtx)); static void reload_cse_move2add PROTO((rtx)); static void move2add_note_store PROTO((rtx, rtx)); +#ifdef AUTO_INC_DEC +static void add_auto_inc_notes PROTO((rtx, rtx)); +#endif /* Initialize the reload pass once per compilation. */ @@ -1124,11 +1127,13 @@ reload (first, global, dumpfile) which are only valid during and after reload. */ reload_completed = 1; - /* Make a pass over all the insns and delete all USEs which we inserted - only to tag a REG_EQUAL note on them. Remove all REG_DEAD and REG_UNUSED - notes. Delete all CLOBBER insns and simplify (subreg (reg)) operands. - Also remove all REG_RETVAL and REG_LIBCALL notes since they are no longer - useful or accurate. */ + /* Make a pass over all the insns and delete all USEs which we + inserted only to tag a REG_EQUAL note on them. Remove all + REG_DEAD and REG_UNUSED notes. Delete all CLOBBER insns and + simplify (subreg (reg)) operands. Also remove all REG_RETVAL and + REG_LIBCALL notes since they are no longer useful or accurate. + Strip and regenerate REG_INC notes that may have been moved + around. */ for (insn = first; insn; insn = NEXT_INSN (insn)) if (GET_RTX_CLASS (GET_CODE (insn)) == 'i') @@ -1150,6 +1155,7 @@ reload (first, global, dumpfile) { if (REG_NOTE_KIND (*pnote) == REG_DEAD || REG_NOTE_KIND (*pnote) == REG_UNUSED + || REG_NOTE_KIND (*pnote) == REG_INC || REG_NOTE_KIND (*pnote) == REG_RETVAL || REG_NOTE_KIND (*pnote) == REG_LIBCALL) *pnote = XEXP (*pnote, 1); @@ -1157,6 +1163,10 @@ reload (first, global, dumpfile) pnote = &XEXP (*pnote, 1); } +#ifdef AUTO_INC_DEC + add_auto_inc_notes (insn, PATTERN (insn)); +#endif + /* And simplify (subreg (reg)) if it appears as an operand. */ cleanup_subreg_operands (insn); } @@ -10131,3 +10141,33 @@ move2add_note_store (dst, set) } } } + +#ifdef AUTO_INC_DEC +static void +add_auto_inc_notes (insn, x) + rtx insn; + rtx x; +{ + enum rtx_code code = GET_CODE (x); + char *fmt; + int i, j; + + if (code == MEM && auto_inc_p (XEXP (x, 0))) + { + REG_NOTES (insn) + = gen_rtx_EXPR_LIST (REG_INC, XEXP (XEXP (x, 0), 0), REG_NOTES (insn)); + return; + } + + /* Scan all the operand sub-expressions. */ + fmt = GET_RTX_FORMAT (code); + for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) + { + if (fmt[i] == 'e') + add_auto_inc_notes (insn, XEXP (x, i)); + else if (fmt[i] == 'E') + for (j = XVECLEN (x, i) - 1; j >= 0; j--) + add_auto_inc_notes (insn, XVECEXP (x, i, j)); + } +} +#endif diff --git a/gcc/rtl.h b/gcc/rtl.h index 7f4460f1934..18489d372b4 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1041,6 +1041,7 @@ extern int computed_jump_p PROTO((rtx)); typedef int (*rtx_function) PROTO((rtx *, void *)); extern int for_each_rtx PROTO((rtx *, rtx_function, void *)); extern rtx regno_use_in PROTO((int, rtx)); +extern int auto_inc_p PROTO((rtx)); /* flow.c */ diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index d061273a172..8347849c6e1 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -2235,3 +2235,27 @@ regno_use_in (regno, x) return NULL_RTX; } + + +/* Return 1 if X is an autoincrement side effect and the register is + not the stack pointer. */ +int +auto_inc_p (x) + rtx x; +{ + switch (GET_CODE (x)) + { + case PRE_INC: + case POST_INC: + case PRE_DEC: + case POST_DEC: + case PRE_MODIFY: + case POST_MODIFY: + /* There are no REG_INC notes for SP. */ + if (XEXP (x, 0) != stack_pointer_rtx) + return 1; + default: + break; + } + return 0; +} -- 2.30.2