This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Updating INSN_STMT records.
> On Mon, Jun 03, 2002 at 06:48:20PM +0200, Jan Hubicka wrote:
> > Actually I was thinking about it more, and we will definitly want to
> > behave differently in some other cases, so probably adding third
> > argument usually used as INSN_STMT (after) sounds more sensible to me.
>
> I thought that's what you meant the first time. ;-)
OK,
the attaches patch implements the idea. It appears to work relatively
reliably.
Wed Jun 5 16:36:45 CEST 2002 Jan Hubicka <jh@suse.cz>
* rtl.h (emit_*_scope): Declare.
* emit-rtl.c (emit_*_scope): New global functions.
(try_split): Copy scope.
* ifcvt.c (noce_try_store_flag, noce_try_store_flag_constants,
noce_try_flag_inc, noce_try_store_flag_mask, noce_try_cmove,
noce_try_cmove_arith, noce_try_minmax, noce_try_abs,
noce_process_if_block, find_cond_trap): Copy scopes.
* recog.c (peephole2_optimize): likewise.
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.270
diff -c -3 -p -r1.270 emit-rtl.c
*** emit-rtl.c 4 Jun 2002 07:07:24 -0000 1.270
--- emit-rtl.c 5 Jun 2002 14:34:18 -0000
*************** try_split (pat, trial, last)
*** 3169,3175 ****
if (GET_CODE (XVECEXP (seq, 0, i)) == INSN)
mark_label_nuses (PATTERN (XVECEXP (seq, 0, i)));
! tem = emit_insn_after (seq, trial);
delete_insn (trial);
if (has_barrier)
--- 3169,3175 ----
if (GET_CODE (XVECEXP (seq, 0, i)) == INSN)
mark_label_nuses (PATTERN (XVECEXP (seq, 0, i)));
! tem = emit_insn_after_scope (seq, trial, INSN_SCOPE (trial));
delete_insn (trial);
if (has_barrier)
*************** emit_line_note_after (file, line, after)
*** 4033,4038 ****
--- 4033,4114 ----
return note;
}
+ /* Like emit_insn_after, but set INSN_SCOPE according to SCOPE. */
+ rtx
+ emit_insn_after_scope (pattern, after, scope)
+ rtx pattern, after;
+ tree scope;
+ {
+ rtx last = emit_insn_after (pattern, after);
+ for (after = NEXT_INSN (after); after != last; after = NEXT_INSN (after))
+ INSN_SCOPE (after) = scope;
+ return last;
+ }
+
+ /* Like emit_insns_after, but set INSN_SCOPE according to SCOPE. */
+ rtx
+ emit_insns_after_scope (pattern, after, scope)
+ rtx pattern, after;
+ tree scope;
+ {
+ rtx last = emit_insns_after (pattern, after);
+ for (after = NEXT_INSN (after); after != last; after = NEXT_INSN (after))
+ INSN_SCOPE (after) = scope;
+ return last;
+ }
+
+ /* Like emit_jump_insn_after, but set INSN_SCOPE according to SCOPE. */
+ rtx
+ emit_jump_insn_after_scope (pattern, after, scope)
+ rtx pattern, after;
+ tree scope;
+ {
+ rtx last = emit_jump_insn_after (pattern, after);
+ for (after = NEXT_INSN (after); after != last; after = NEXT_INSN (after))
+ INSN_SCOPE (after) = scope;
+ return last;
+ }
+
+ /* Like emit_call_insn_after, but set INSN_SCOPE according to SCOPE. */
+ rtx
+ emit_call_insn_after_scope (pattern, after, scope)
+ rtx pattern, after;
+ tree scope;
+ {
+ rtx last = emit_call_insn_after (pattern, after);
+ for (after = NEXT_INSN (after); after != last; after = NEXT_INSN (after))
+ INSN_SCOPE (after) = scope;
+ return last;
+ }
+
+ /* Like emit_insn_before, but set INSN_SCOPE according to SCOPE. */
+ rtx
+ emit_insn_before_scope (pattern, before, scope)
+ rtx pattern, before;
+ tree scope;
+ {
+ rtx first = PREV_INSN (before);
+ rtx last = emit_insn_before (pattern, before);
+
+ for (first = NEXT_INSN (first); first != last; first = NEXT_INSN (first))
+ INSN_SCOPE (first) = scope;
+ return last;
+ }
+
+ /* Like emit_insns_before, but set INSN_SCOPE according to SCOPE. */
+ rtx
+ emit_insns_before_scope (pattern, before, scope)
+ rtx pattern, before;
+ tree scope;
+ {
+ rtx first = PREV_INSN (before);
+ rtx last = emit_insns_before (pattern, before);
+
+ for (first = NEXT_INSN (first); first != last; first = NEXT_INSN (first))
+ INSN_SCOPE (first) = scope;
+ return last;
+ }
+
/* Make an insn of code INSN with pattern PATTERN
and add it to the end of the doubly-linked list.
If PATTERN is a SEQUENCE, take the elements of it
Index: ifcvt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ifcvt.c,v
retrieving revision 1.93
diff -c -3 -p -r1.93 ifcvt.c
*** ifcvt.c 28 May 2002 12:53:43 -0000 1.93
--- ifcvt.c 5 Jun 2002 14:34:18 -0000
*************** noce_try_store_flag (if_info)
*** 612,618 ****
seq = get_insns ();
end_sequence ();
! emit_insns_before (seq, if_info->jump);
return TRUE;
}
--- 612,618 ----
seq = get_insns ();
end_sequence ();
! emit_insns_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
return TRUE;
}
*************** noce_try_store_flag_constants (if_info)
*** 747,753 ****
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before (seq, if_info->jump);
return TRUE;
}
--- 747,753 ----
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
return TRUE;
}
*************** noce_try_store_flag_inc (if_info)
*** 807,813 ****
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before (seq, if_info->jump);
return TRUE;
}
--- 807,814 ----
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before_scope (seq, if_info->jump,
! INSN_SCOPE (if_info->insn_a));
return TRUE;
}
*************** noce_try_store_flag_mask (if_info)
*** 859,865 ****
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before (seq, if_info->jump);
return TRUE;
}
--- 860,867 ----
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before_scope (seq, if_info->jump,
! INSN_SCOPE (if_info->insn_a));
return TRUE;
}
*************** noce_try_cmove (if_info)
*** 954,960 ****
seq = get_insns ();
end_sequence ();
! emit_insns_before (seq, if_info->jump);
return TRUE;
}
else
--- 956,963 ----
seq = get_insns ();
end_sequence ();
! emit_insns_before_scope (seq, if_info->jump,
! INSN_SCOPE (if_info->insn_a));
return TRUE;
}
else
*************** noce_try_cmove_arith (if_info)
*** 1116,1122 ****
tmp = get_insns ();
end_sequence ();
! emit_insns_before (tmp, if_info->jump);
return TRUE;
end_seq_and_fail:
--- 1119,1125 ----
tmp = get_insns ();
end_sequence ();
! emit_insns_before_scope (tmp, if_info->jump, INSN_SCOPE (if_info->insn_a));
return TRUE;
end_seq_and_fail:
*************** noce_try_minmax (if_info)
*** 1368,1374 ****
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before (seq, if_info->jump);
if_info->cond = cond;
if_info->cond_earliest = earliest;
--- 1371,1377 ----
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
if_info->cond = cond;
if_info->cond_earliest = earliest;
*************** noce_try_abs (if_info)
*** 1486,1492 ****
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before (seq, if_info->jump);
if_info->cond = cond;
if_info->cond_earliest = earliest;
--- 1489,1495 ----
if (seq_contains_jump (seq))
return FALSE;
! emit_insns_before_scope (seq, if_info->jump, INSN_SCOPE (if_info->insn_a));
if_info->cond = cond;
if_info->cond_earliest = earliest;
*************** noce_process_if_block (test_bb, then_bb,
*** 1758,1764 ****
insn_b = gen_sequence ();
end_sequence ();
! emit_insn_after (insn_b, test_bb->end);
}
/* Merge the blocks! */
--- 1761,1767 ----
insn_b = gen_sequence ();
end_sequence ();
! emit_insn_after_scope (insn_b, test_bb->end, INSN_SCOPE (insn_a));
}
/* Merge the blocks! */
*************** find_cond_trap (test_bb, then_edge, else
*** 2126,2132 ****
return FALSE;
/* Emit the new insns before cond_earliest. */
! emit_insn_before (seq, cond_earliest);
/* Delete the trap block if possible. */
remove_edge (trap_bb == then_bb ? then_edge : else_edge);
--- 2129,2135 ----
return FALSE;
/* Emit the new insns before cond_earliest. */
! emit_insns_before_scope (seq, cond_earliest, INSN_SCOPE (trap));
/* Delete the trap block if possible. */
remove_edge (trap_bb == then_bb ? then_edge : else_edge);
Index: recog.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/recog.c,v
retrieving revision 1.157
diff -c -3 -p -r1.157 recog.c
*** recog.c 2 Jun 2002 21:09:39 -0000 1.157
--- recog.c 5 Jun 2002 14:34:21 -0000
*************** peephole2_optimize (dump_file)
*** 3133,3139 ****
REG_EH_REGION, NULL_RTX);
/* Replace the old sequence with the new. */
! try = emit_insn_after (try, peep2_insn_data[i].insn);
before_try = PREV_INSN (insn);
delete_insn_chain (insn, peep2_insn_data[i].insn);
--- 3133,3140 ----
REG_EH_REGION, NULL_RTX);
/* Replace the old sequence with the new. */
! try = emit_insn_after_scope (try, peep2_insn_data[i].insn,
! INSN_SCOPE (peep2_insn_data[i].insn));
before_try = PREV_INSN (insn);
delete_insn_chain (insn, peep2_insn_data[i].insn);
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.354
diff -c -3 -p -r1.354 rtl.h
*** rtl.h 4 Jun 2002 17:32:57 -0000 1.354
--- rtl.h 5 Jun 2002 14:34:22 -0000
*************** extern rtx assign_stack_temp_for_type PA
*** 1373,1386 ****
--- 1373,1392 ----
extern rtx assign_temp PARAMS ((tree, int, int, int));
/* In emit-rtl.c */
extern rtx emit_insn_before PARAMS ((rtx, rtx));
+ extern rtx emit_insn_before_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_jump_insn_before PARAMS ((rtx, rtx));
+ extern rtx emit_jump_insn_before_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_call_insn_before PARAMS ((rtx, rtx));
+ extern rtx emit_call_insn_before_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_barrier_before PARAMS ((rtx));
extern rtx emit_label_before PARAMS ((rtx, rtx));
extern rtx emit_note_before PARAMS ((int, rtx));
extern rtx emit_insn_after PARAMS ((rtx, rtx));
+ extern rtx emit_insn_after_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_jump_insn_after PARAMS ((rtx, rtx));
+ extern rtx emit_jump_insn_after_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_call_insn_after PARAMS ((rtx, rtx));
+ extern rtx emit_call_insn_after_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_barrier_after PARAMS ((rtx));
extern rtx emit_label_after PARAMS ((rtx, rtx));
extern rtx emit_note_after PARAMS ((int, rtx));
*************** extern rtx emit_line_note_after PARAMS
*** 1388,1394 ****
--- 1394,1402 ----
extern rtx emit_insn PARAMS ((rtx));
extern rtx emit_insns PARAMS ((rtx));
extern rtx emit_insns_before PARAMS ((rtx, rtx));
+ extern rtx emit_insns_before_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_insns_after PARAMS ((rtx, rtx));
+ extern rtx emit_insns_after_scope PARAMS ((rtx, rtx, tree));
extern rtx emit_jump_insn PARAMS ((rtx));
extern rtx emit_call_insn PARAMS ((rtx));
extern rtx emit_label PARAMS ((rtx));