Regtested cris-elf. Ok to commit? -- >8 -- No functional change.
- We always have a target_hash_table and bb_ticks because init_resource_info is always called. These conditionals are an ancient artifact: it's been quite a while since resource.cc was used elsewhere than exclusively from reorg.cc - In mark_target_live_regs, get rid of a now-redundant "if (tinfo != NULL)" conditional and replace an "if (bb)" with a gcc_assert. A "git diff -wb" (ignore whitespace diff) is better at showing the actual changes. * resource.cc (free_resource_info, clear_hashed_info_for_insn): Don't check for non-null target_hash_table and bb_ticks. (mark_target_live_regs): Ditto. Replace check for non-NULL result from BLOCK_FOR_INSN with a call to gcc_assert. Fold code conditioned on tinfo != NULL. --- gcc/resource.cc | 123 ++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 71 deletions(-) diff --git a/gcc/resource.cc b/gcc/resource.cc index 62bd46f786eb..7c1de8864327 100644 --- a/gcc/resource.cc +++ b/gcc/resource.cc @@ -658,49 +658,42 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource res->cc = 0; /* See if we have computed this value already. */ - if (target_hash_table != NULL) - { - for (tinfo = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; - tinfo; tinfo = tinfo->next) - if (tinfo->uid == INSN_UID (target)) - break; - - /* Start by getting the basic block number. If we have saved - information, we can get it from there unless the insn at the - start of the basic block has been deleted. */ - if (tinfo && tinfo->block != -1 - && ! BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, tinfo->block))->deleted ()) - b = tinfo->block; - } + for (tinfo = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; + tinfo; tinfo = tinfo->next) + if (tinfo->uid == INSN_UID (target)) + break; + + /* Start by getting the basic block number. If we have saved + information, we can get it from there unless the insn at the + start of the basic block has been deleted. */ + if (tinfo && tinfo->block != -1 + && ! BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, tinfo->block))->deleted ()) + b = tinfo->block; if (b == -1) b = BLOCK_FOR_INSN (target)->index; gcc_assert (b != -1); - if (target_hash_table != NULL) + if (tinfo) { - if (tinfo) + /* If the information is up-to-date, use it. Otherwise, we will + update it below. */ + if (b == tinfo->block && tinfo->bb_tick == bb_ticks[b]) { - /* If the information is up-to-date, use it. Otherwise, we will - update it below. */ - if (b == tinfo->block && tinfo->bb_tick == bb_ticks[b]) - { - res->regs = tinfo->live_regs; - return; - } - } - else - { - /* Allocate a place to put our results and chain it into the - hash table. */ - tinfo = XNEW (struct target_info); - tinfo->uid = INSN_UID (target); - tinfo->block = b; - tinfo->next - = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; - target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME] = tinfo; + res->regs = tinfo->live_regs; + return; } } + else + { + /* Allocate a place to put our results and chain it into the hash + table. */ + tinfo = XNEW (struct target_info); + tinfo->uid = INSN_UID (target); + tinfo->block = b; + tinfo->next = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; + target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME] = tinfo; + } CLEAR_HARD_REG_SET (pending_dead_regs); @@ -825,13 +818,12 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource to be live here still are. The fallthrough edge may have left a live register uninitialized. */ bb = BLOCK_FOR_INSN (real_insn); - if (bb) - { - HARD_REG_SET extra_live; + gcc_assert (bb); - REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb)); - current_live_regs |= extra_live; - } + HARD_REG_SET extra_live; + + REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb)); + current_live_regs |= extra_live; } /* The beginning of the epilogue corresponds to the end of the @@ -847,10 +839,8 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource { tinfo->block = b; tinfo->bb_tick = bb_ticks[b]; + tinfo->live_regs = res->regs; } - - if (tinfo != NULL) - tinfo->live_regs = res->regs; } /* Initialize the resources required by mark_target_live_regs (). @@ -939,31 +929,25 @@ init_resource_info (rtx_insn *epilogue_insn) void free_resource_info (void) { - if (target_hash_table != NULL) + int i; + + for (i = 0; i < TARGET_HASH_PRIME; ++i) { - int i; + struct target_info *ti = target_hash_table[i]; - for (i = 0; i < TARGET_HASH_PRIME; ++i) + while (ti) { - struct target_info *ti = target_hash_table[i]; - - while (ti) - { - struct target_info *next = ti->next; - free (ti); - ti = next; - } + struct target_info *next = ti->next; + free (ti); + ti = next; } - - free (target_hash_table); - target_hash_table = NULL; } - if (bb_ticks != NULL) - { - free (bb_ticks); - bb_ticks = NULL; - } + free (target_hash_table); + target_hash_table = NULL; + + free (bb_ticks); + bb_ticks = NULL; free_bb_for_insn (); } @@ -975,16 +959,13 @@ clear_hashed_info_for_insn (rtx_insn *insn) { struct target_info *tinfo; - if (target_hash_table != NULL) - { - for (tinfo = target_hash_table[INSN_UID (insn) % TARGET_HASH_PRIME]; - tinfo; tinfo = tinfo->next) - if (tinfo->uid == INSN_UID (insn)) - break; + for (tinfo = target_hash_table[INSN_UID (insn) % TARGET_HASH_PRIME]; + tinfo; tinfo = tinfo->next) + if (tinfo->uid == INSN_UID (insn)) + break; - if (tinfo) - tinfo->block = -1; - } + if (tinfo) + tinfo->block = -1; } /* Clear any hashed information that we have stored for instructions -- 2.30.2