From fe477d8b5bc4d62f7592f5468a3c070ec47c0c95 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 6 Mar 2002 18:16:22 +0100 Subject: [PATCH] cfgcleanup.c (mentions_nonequal_regs): New function. * cfgcleanup.c (mentions_nonequal_regs): New function. (thread_jump): Use it. * toplev.c (rest_of_compilation): Run jump threading after liveness. From-SVN: r50361 --- gcc/ChangeLog | 7 +++++++ gcc/cfgcleanup.c | 32 ++++++++++++++++++++++++++++++++ gcc/toplev.c | 3 ++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 30c3e07dcbf..3b89fa44560 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +Wed Mar 6 18:14:43 CET 2002 Jan Hubicka + + * cfgcleanup.c (mentions_nonequal_regs): New function. + (thread_jump): Use it. + * toplev.c (rest_of_compilation): Run jump threading after + liveness. + 2002-03-06 Jakub Jelinek * ssa-ccp.c (ssa_ccp_substitute_constants): Backout 2002-03-05 diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index a4dccbea805..bce4153def0 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -89,6 +89,7 @@ static edge thread_jump PARAMS ((int, edge, basic_block)); static bool mark_effect PARAMS ((rtx, bitmap)); static void notice_new_block PARAMS ((basic_block)); static void update_forwarder_flag PARAMS ((basic_block)); +static int mentions_nonequal_regs PARAMS ((rtx *, void *)); /* Set flags for newly created block. */ @@ -235,6 +236,32 @@ mark_effect (exp, nonequal) return false; } } + +/* Return nonzero if X is an register set in regset DATA. + Called via for_each_rtx. */ +static int +mentions_nonequal_regs (x, data) + rtx *x; + void *data; +{ + regset nonequal = (regset) data; + if (REG_P (*x)) + { + int regno; + + regno = REGNO (*x); + if (REGNO_REG_SET_P (nonequal, regno)) + return 1; + if (regno < FIRST_PSEUDO_REGISTER) + { + int n = HARD_REGNO_NREGS (regno, GET_MODE (*x)); + while (--n > 0) + if (REGNO_REG_SET_P (nonequal, regno + n)) + return 1; + } + } + return 0; +} /* Attempt to prove that the basic block B will have no side effects and allways continues in the same edge if reached via E. Return the edge if exist, NULL otherwise. */ @@ -338,6 +365,11 @@ thread_jump (mode, e, b) if (failed) goto failed_exit; + /* cond2 must not mention any register that is not equal to the + former block. */ + if (for_each_rtx (&cond2, mentions_nonequal_regs, nonequal)) + goto failed_exit; + /* In case liveness information is available, we need to prove equivalence only of the live values. */ if (mode & CLEANUP_UPDATE_LIFE) diff --git a/gcc/toplev.c b/gcc/toplev.c index f97db602350..5cd2e44ad17 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -3019,7 +3019,8 @@ rest_of_compilation (decl) #endif life_analysis (insns, rtl_dump_file, PROP_FINAL); if (optimize) - cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE); + cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) + | (flag_thread_jumps ? CLEANUP_THREADING : 0)); timevar_pop (TV_FLOW); no_new_pseudos = 1;