This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
combine and noop moves, take 2
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, patches at x86-64 dot org
- Subject: combine and noop moves, take 2
- From: Jan Hubicka <hubicka at atrey dot karlin dot mff dot cuni dot cz>
- Date: Fri, 20 Jul 2001 22:38:12 +0200
Hi
Thinking about it more, I don't need update life, as it should be up-to-date
already, because noop moves with REG_DEAD notes should be removed
while updating life information after combine.
I've managed to confuse myself thinking on the fact that combine can't
remove the noop moves immediately to not mess up the REG_DEAD notes
and log links.
Bootstrapped/regtested mips, i686 in progress.
OK?
Honza
Fri Jul 20 15:58:44 CEST 2001 Jan Hubicka <jh@suse.cz>
* basic-block.h (delete_noop_moves): Declare.
* combine.c (combine_instructions): Call it.
(recog_for_combine): Tolerate noop moves
* flow.c (delete_noop_moves): Use BB structure; delete JUMP insns
too.
(life_analysis): Update delete_noop_moves call.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.219
diff -c -3 -p -r1.219 combine.c
*** combine.c 2001/07/20 17:47:03 1.219
--- combine.c 2001/07/20 20:35:41
*************** combine_instructions (f, nregs)
*** 755,760 ****
--- 755,762 ----
/* Make recognizer allow volatile MEMs again. */
init_recog ();
+ delete_noop_moves (f);
+
return new_direct_jump_p;
}
*************** recog_for_combine (pnewpat, insn, pnotes
*** 9598,9605 ****
old_notes = REG_NOTES (insn);
REG_NOTES (insn) = 0;
! /* Is the result of combination a valid instruction? */
! insn_code_number = recog (pat, insn, &num_clobbers_to_add);
/* If it isn't, there is the possibility that we previously had an insn
that clobbered some register as a side effect, but the combined
--- 9600,9611 ----
old_notes = REG_NOTES (insn);
REG_NOTES (insn) = 0;
! /* Is the result of combination a valid instruction?
! Recognize all noop sets, these will be killed by followup pass. */
! if (GET_CODE (pat) == SET && set_noop_p (pat))
! insn_code_number = 0;
! else
! insn_code_number = recog (pat, insn, &num_clobbers_to_add);
/* If it isn't, there is the possibility that we previously had an insn
that clobbered some register as a side effect, but the combined
*************** recog_for_combine (pnewpat, insn, pnotes
*** 9624,9630 ****
if (pos == 1)
pat = XVECEXP (pat, 0, 0);
! insn_code_number = recog (pat, insn, &num_clobbers_to_add);
}
REG_NOTES (insn) = old_notes;
--- 9630,9640 ----
if (pos == 1)
pat = XVECEXP (pat, 0, 0);
! /* Recognize all noop sets, these will be killed by followup pass. */
! if (GET_CODE (pat) == SET && set_noop_p (pat))
! insn_code_number = 0;
! else
! insn_code_number = recog (pat, insn, &num_clobbers_to_add);
}
REG_NOTES (insn) = old_notes;
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/basic-block.h,v
retrieving revision 1.102
diff -c -3 -p -r1.102 basic-block.h
*** basic-block.h 2001/07/16 20:54:42 1.102
--- basic-block.h 2001/07/20 20:35:42
*************** extern void debug_regset PARAMS ((regse
*** 597,602 ****
--- 597,603 ----
extern void allocate_reg_life_data PARAMS ((void));
extern void allocate_bb_life_data PARAMS ((void));
extern void find_unreachable_blocks PARAMS ((void));
+ extern void delete_noop_moves PARAMS ((rtx));
/* This function is always defined so it can be called from the
debugger, and it is declared extern so we don't get warnings about
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.430
diff -c -3 -p -r1.430 flow.c
*** flow.c 2001/07/18 17:11:10 1.430
--- flow.c 2001/07/20 20:35:46
*************** static int verify_wide_reg_1 PARAMS ((r
*** 403,409 ****
static void verify_wide_reg PARAMS ((int, rtx, rtx));
static void verify_local_live_at_start PARAMS ((regset, basic_block));
static int noop_move_p PARAMS ((rtx));
- static void delete_noop_moves PARAMS ((rtx));
static void notice_stack_pointer_modification_1 PARAMS ((rtx, rtx, void *));
static void notice_stack_pointer_modification PARAMS ((rtx));
static void mark_reg PARAMS ((rtx, void *));
--- 403,408 ----
*************** noop_move_p (insn)
*** 4246,4263 ****
/* Delete any insns that copy a register to itself. */
! static void
delete_noop_moves (f)
rtx f;
{
! rtx insn;
! for (insn = f; insn; insn = NEXT_INSN (insn))
{
! if (GET_CODE (insn) == INSN && noop_move_p (insn))
{
! PUT_CODE (insn, NOTE);
! NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
! NOTE_SOURCE_FILE (insn) = 0;
}
}
}
--- 4245,4270 ----
/* Delete any insns that copy a register to itself. */
! void
delete_noop_moves (f)
rtx f;
{
! int i;
! rtx insn, next;
! basic_block bb;
!
! for (i = 0; i < n_basic_blocks; i++)
{
! bb = BASIC_BLOCK (i);
! for (insn = bb->head; insn != NEXT_INSN (bb->end); insn = next)
{
! next = NEXT_INSN (insn);
! if (INSN_P (insn) && noop_move_p (insn))
! {
! if (insn == bb->end)
! bb->end = PREV_INSN (insn);
! flow_delete_insn (insn);
! }
}
}
}