This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
remove ADDR_VEC handling from jump.c
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, patches at x86-64 dot org
- Subject: remove ADDR_VEC handling from jump.c
- From: Jan Hubicka <jh at suse dot cz>
- Date: Fri, 29 Jun 2001 15:18:21 +0200
Hi,
I still can't kill most of logic from jump.c, as the code quallity suffers
(probably because the late jump passes don't work well if jump don't cleanup
as does currently).
I can at least remove the ADDR_VEC handling code, as it seems to be complettely
obsoletted by try_optimize_cfg now.
I am even getting code qualitty improvements for some purpose.
Honza
Fri Jun 29 15:15:25 CEST 2001 Jan Hubicka <jh@suse.cz>
* jump.c (tension_vector_labels, delete_labelref_insn,
redirect_tablejump): Kill.
(jump_optimize_1): Do not attempt to tension tablejumps
nor replace them by jump.
Index: jump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/jump.c,v
retrieving revision 1.178
diff -c -3 -p -r1.178 jump.c
*** jump.c 2001/06/11 13:49:24 1.178
--- jump.c 2001/06/29 13:15:01
*************** static int duplicate_loop_exit_test PARA
*** 113,128 ****
static void find_cross_jump PARAMS ((rtx, rtx, int, rtx *, rtx *));
static void do_cross_jump PARAMS ((rtx, rtx, rtx));
static int jump_back_p PARAMS ((rtx, rtx));
- static int tension_vector_labels PARAMS ((rtx, int));
static void delete_computation PARAMS ((rtx));
static void redirect_exp_1 PARAMS ((rtx *, rtx, rtx, rtx));
static int redirect_exp PARAMS ((rtx, rtx, rtx));
static void invert_exp_1 PARAMS ((rtx));
static int invert_exp PARAMS ((rtx));
static void delete_from_jump_chain PARAMS ((rtx));
- static int delete_labelref_insn PARAMS ((rtx, rtx, int));
static void mark_modified_reg PARAMS ((rtx, rtx, void *));
- static void redirect_tablejump PARAMS ((rtx, rtx));
static void jump_optimize_1 PARAMS ((rtx, int, int, int, int, int));
static int returnjump_p_1 PARAMS ((rtx *, void *));
static void delete_prior_computation PARAMS ((rtx, rtx));
--- 113,125 ----
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 294,306 ****
this_is_any_uncondjump = any_uncondjump_p (insn);
this_is_onlyjump = onlyjump_p (insn);
- /* Tension the labels in dispatch tables. */
-
- if (GET_CODE (PATTERN (insn)) == ADDR_VEC)
- changed |= tension_vector_labels (PATTERN (insn), 0);
- if (GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
- changed |= tension_vector_labels (PATTERN (insn), 1);
-
/* See if this jump goes to another jump and redirect if so. */
nlabel = follow_jumps (JUMP_LABEL (insn));
if (nlabel != JUMP_LABEL (insn))
--- 291,296 ----
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 309,350 ****
if (! optimize || minimal)
continue;
- /* If a dispatch table always goes to the same place,
- get rid of it and replace the insn that uses it. */
-
- if (GET_CODE (PATTERN (insn)) == ADDR_VEC
- || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
- {
- int i;
- rtx pat = PATTERN (insn);
- int diff_vec_p = GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC;
- int len = XVECLEN (pat, diff_vec_p);
- rtx dispatch = prev_real_insn (insn);
- rtx set;
-
- for (i = 0; i < len; i++)
- if (XEXP (XVECEXP (pat, diff_vec_p, i), 0)
- != XEXP (XVECEXP (pat, diff_vec_p, 0), 0))
- break;
-
- if (i == len
- && dispatch != 0
- && GET_CODE (dispatch) == JUMP_INSN
- && JUMP_LABEL (dispatch) != 0
- /* Don't mess with a casesi insn.
- XXX according to the comment before computed_jump_p(),
- all casesi insns should be a parallel of the jump
- and a USE of a LABEL_REF. */
- && ! ((set = single_set (dispatch)) != NULL
- && (GET_CODE (SET_SRC (set)) == IF_THEN_ELSE))
- && next_real_insn (JUMP_LABEL (dispatch)) == insn)
- {
- redirect_tablejump (dispatch,
- XEXP (XVECEXP (pat, diff_vec_p, 0), 0));
- changed = 1;
- }
- }
-
reallabelprev = prev_active_insn (JUMP_LABEL (insn));
/* Detect jump to following insn. */
--- 299,304 ----
*************** follow_jumps (label)
*** 2431,2464 ****
return label;
return value;
}
-
- /* Assuming that field IDX of X is a vector of label_refs,
- replace each of them by the ultimate label reached by it.
- Return nonzero if a change is made.
- If IGNORE_LOOPS is 0, we do not chain across a NOTE_INSN_LOOP_BEG. */
-
- static int
- tension_vector_labels (x, idx)
- register rtx x;
- register int idx;
- {
- int changed = 0;
- register int i;
- for (i = XVECLEN (x, idx) - 1; i >= 0; i--)
- {
- register rtx olabel = XEXP (XVECEXP (x, idx, i), 0);
- register rtx nlabel = follow_jumps (olabel);
- if (nlabel && nlabel != olabel)
- {
- XEXP (XVECEXP (x, idx, i), 0) = nlabel;
- ++LABEL_NUSES (nlabel);
- if (--LABEL_NUSES (olabel) == 0)
- delete_insn (olabel);
- changed = 1;
- }
- }
- return changed;
- }
/* Find all CODE_LABELs referred to in X, and increment their use counts.
If INSN is a JUMP_INSN and there is at least one CODE_LABEL referenced
--- 2385,2390 ----
*************** delete_from_jump_chain (jump)
*** 3417,3511 ****
break;
}
}
- }
-
- /* Make jump JUMP jump to label NLABEL, assuming it used to be a tablejump.
-
- If the old jump target label (before the dispatch table) becomes unused,
- it and the dispatch table may be deleted. In that case, find the insn
- before the jump references that label and delete it and logical successors
- too. */
-
- static void
- redirect_tablejump (jump, nlabel)
- rtx jump, nlabel;
- {
- register rtx olabel = JUMP_LABEL (jump);
- rtx *notep, note, next;
-
- /* Add this jump to the jump_chain of NLABEL. */
- if (jump_chain && INSN_UID (nlabel) < max_jump_chain
- && INSN_UID (jump) < max_jump_chain)
- {
- jump_chain[INSN_UID (jump)] = jump_chain[INSN_UID (nlabel)];
- jump_chain[INSN_UID (nlabel)] = jump;
- }
-
- for (notep = ®_NOTES (jump), note = *notep; note; note = next)
- {
- next = XEXP (note, 1);
-
- if (REG_NOTE_KIND (note) != REG_DEAD
- /* Verify that the REG_NOTE is legitimate. */
- || GET_CODE (XEXP (note, 0)) != REG
- || ! reg_mentioned_p (XEXP (note, 0), PATTERN (jump)))
- notep = &XEXP (note, 1);
- else
- {
- delete_prior_computation (note, jump);
- *notep = next;
- }
- }
-
- PATTERN (jump) = gen_jump (nlabel);
- JUMP_LABEL (jump) = nlabel;
- ++LABEL_NUSES (nlabel);
- INSN_CODE (jump) = -1;
-
- if (--LABEL_NUSES (olabel) == 0)
- {
- delete_labelref_insn (jump, olabel, 0);
- delete_insn (olabel);
- }
- }
-
- /* Find the insn referencing LABEL that is a logical predecessor of INSN.
- If we found one, delete it and then delete this insn if DELETE_THIS is
- non-zero. Return non-zero if INSN or a predecessor references LABEL. */
-
- static int
- delete_labelref_insn (insn, label, delete_this)
- rtx insn, label;
- int delete_this;
- {
- int deleted = 0;
- rtx link;
-
- if (GET_CODE (insn) != NOTE
- && reg_mentioned_p (label, PATTERN (insn)))
- {
- if (delete_this)
- {
- delete_insn (insn);
- deleted = 1;
- }
- else
- return 1;
- }
-
- for (link = LOG_LINKS (insn); link; link = XEXP (link, 1))
- if (delete_labelref_insn (XEXP (link, 0), label, 1))
- {
- if (delete_this)
- {
- delete_insn (insn);
- deleted = 1;
- }
- else
- return 1;
- }
-
- return deleted;
}
/* Like rtx_equal_p except that it considers two REGs as equal
--- 3343,3348 ----