Commit 99a15921 by Jeff Law Committed by Jeff Law

gcse.c (delete_null_pointer_checks_1): Inform caller if any null pointer checks were eliminated.


        * gcse.c (delete_null_pointer_checks_1): Inform caller if any
        null pointer checks were eliminated.  Update prototype.
        (delete_null_pointer_checks): Similarly.
        * rtl.h (delete_null_pointer_checks): Update prototype.
        * toplev.c (rest_of_compilation): Only run cleanup_cfg if
        delete_null_pointer_checks deletes one or more null
        pointer checks.  Do not run cleanup_cfg before gcse, the
        CFG is accurate and optimized at that point..

From-SVN: r54617
parent e56c4463
2002-06-13 Jeffrey Law <law@redhat.com> 2002-06-13 Jeffrey Law <law@redhat.com>
* gcse.c (delete_null_pointer_checks_1): Inform caller if any
null pointer checks were eliminated. Update prototype.
(delete_null_pointer_checks): Similarly.
* rtl.h (delete_null_pointer_checks): Update prototype.
* toplev.c (rest_of_compilation): Only run cleanup_cfg if
delete_null_pointer_checks deletes one or more null
pointer checks. Do not run cleanup_cfg before gcse, the
CFG is accurate and optimized at that point..
* rs6000.c (rs6000_frame_related): Avoid unwanted sharing * rs6000.c (rs6000_frame_related): Avoid unwanted sharing
of hard registers. of hard registers.
......
...@@ -658,7 +658,7 @@ static int handle_avail_expr PARAMS ((rtx, struct expr *)); ...@@ -658,7 +658,7 @@ static int handle_avail_expr PARAMS ((rtx, struct expr *));
static int classic_gcse PARAMS ((void)); static int classic_gcse PARAMS ((void));
static int one_classic_gcse_pass PARAMS ((int)); static int one_classic_gcse_pass PARAMS ((int));
static void invalidate_nonnull_info PARAMS ((rtx, rtx, void *)); static void invalidate_nonnull_info PARAMS ((rtx, rtx, void *));
static void delete_null_pointer_checks_1 PARAMS ((unsigned int *, static int delete_null_pointer_checks_1 PARAMS ((unsigned int *,
sbitmap *, sbitmap *, sbitmap *, sbitmap *,
struct null_pointer_info *)); struct null_pointer_info *));
static rtx process_insert_insn PARAMS ((struct expr *)); static rtx process_insert_insn PARAMS ((struct expr *));
...@@ -5473,7 +5473,7 @@ invalidate_nonnull_info (x, setter, data) ...@@ -5473,7 +5473,7 @@ invalidate_nonnull_info (x, setter, data)
NPI. NONNULL_AVIN and NONNULL_AVOUT are pre-allocated sbitmaps; NPI. NONNULL_AVIN and NONNULL_AVOUT are pre-allocated sbitmaps;
they are not our responsibility to free. */ they are not our responsibility to free. */
static void static int
delete_null_pointer_checks_1 (block_reg, nonnull_avin, delete_null_pointer_checks_1 (block_reg, nonnull_avin,
nonnull_avout, npi) nonnull_avout, npi)
unsigned int *block_reg; unsigned int *block_reg;
...@@ -5484,6 +5484,7 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin, ...@@ -5484,6 +5484,7 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin,
basic_block bb, current_block; basic_block bb, current_block;
sbitmap *nonnull_local = npi->nonnull_local; sbitmap *nonnull_local = npi->nonnull_local;
sbitmap *nonnull_killed = npi->nonnull_killed; sbitmap *nonnull_killed = npi->nonnull_killed;
int something_changed = 0;
/* Compute local properties, nonnull and killed. A register will have /* Compute local properties, nonnull and killed. A register will have
the nonnull property if at the end of the current block its value is the nonnull property if at the end of the current block its value is
...@@ -5605,6 +5606,7 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin, ...@@ -5605,6 +5606,7 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin,
emit_barrier_after (new_jump); emit_barrier_after (new_jump);
} }
something_changed = 1;
delete_insn (last_insn); delete_insn (last_insn);
if (compare_and_branch == 2) if (compare_and_branch == 2)
delete_insn (earliest); delete_insn (earliest);
...@@ -5615,6 +5617,8 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin, ...@@ -5615,6 +5617,8 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin,
block.) */ block.) */
block_reg[bb->index] = 0; block_reg[bb->index] = 0;
} }
return something_changed;
} }
/* Find EQ/NE comparisons against zero which can be (indirectly) evaluated /* Find EQ/NE comparisons against zero which can be (indirectly) evaluated
...@@ -5641,7 +5645,7 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin, ...@@ -5641,7 +5645,7 @@ delete_null_pointer_checks_1 (block_reg, nonnull_avin,
This could probably be integrated with global cprop with a little work. */ This could probably be integrated with global cprop with a little work. */
void int
delete_null_pointer_checks (f) delete_null_pointer_checks (f)
rtx f ATTRIBUTE_UNUSED; rtx f ATTRIBUTE_UNUSED;
{ {
...@@ -5652,10 +5656,11 @@ delete_null_pointer_checks (f) ...@@ -5652,10 +5656,11 @@ delete_null_pointer_checks (f)
int regs_per_pass; int regs_per_pass;
int max_reg; int max_reg;
struct null_pointer_info npi; struct null_pointer_info npi;
int something_changed = 0;
/* If we have only a single block, then there's nothing to do. */ /* If we have only a single block, then there's nothing to do. */
if (n_basic_blocks <= 1) if (n_basic_blocks <= 1)
return; return 0;
/* Trying to perform global optimizations on flow graphs which have /* Trying to perform global optimizations on flow graphs which have
a high connectivity will take a long time and is unlikely to be a high connectivity will take a long time and is unlikely to be
...@@ -5666,7 +5671,7 @@ delete_null_pointer_checks (f) ...@@ -5666,7 +5671,7 @@ delete_null_pointer_checks (f)
a couple switch statements. So we require a relatively large number a couple switch statements. So we require a relatively large number
of basic blocks and the ratio of edges to blocks to be high. */ of basic blocks and the ratio of edges to blocks to be high. */
if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20) if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20)
return; return 0;
/* We need four bitmaps, each with a bit for each register in each /* We need four bitmaps, each with a bit for each register in each
basic block. */ basic block. */
...@@ -5719,8 +5724,10 @@ delete_null_pointer_checks (f) ...@@ -5719,8 +5724,10 @@ delete_null_pointer_checks (f)
{ {
npi.min_reg = reg; npi.min_reg = reg;
npi.max_reg = MIN (reg + regs_per_pass, max_reg); npi.max_reg = MIN (reg + regs_per_pass, max_reg);
delete_null_pointer_checks_1 (block_reg, nonnull_avin, something_changed |= delete_null_pointer_checks_1 (block_reg,
nonnull_avout, &npi); nonnull_avin,
nonnull_avout,
&npi);
} }
/* Free the table of registers compared at the end of every block. */ /* Free the table of registers compared at the end of every block. */
...@@ -5731,6 +5738,8 @@ delete_null_pointer_checks (f) ...@@ -5731,6 +5738,8 @@ delete_null_pointer_checks (f)
sbitmap_vector_free (npi.nonnull_killed); sbitmap_vector_free (npi.nonnull_killed);
sbitmap_vector_free (nonnull_avin); sbitmap_vector_free (nonnull_avin);
sbitmap_vector_free (nonnull_avout); sbitmap_vector_free (nonnull_avout);
return something_changed;
} }
/* Code Hoisting variables and subroutines. */ /* Code Hoisting variables and subroutines. */
......
...@@ -2035,7 +2035,7 @@ extern void reg_scan PARAMS ((rtx, unsigned int, int)); ...@@ -2035,7 +2035,7 @@ extern void reg_scan PARAMS ((rtx, unsigned int, int));
extern void reg_scan_update PARAMS ((rtx, rtx, unsigned int)); extern void reg_scan_update PARAMS ((rtx, rtx, unsigned int));
extern void fix_register PARAMS ((const char *, int, int)); extern void fix_register PARAMS ((const char *, int, int));
extern void delete_null_pointer_checks PARAMS ((rtx)); extern int delete_null_pointer_checks PARAMS ((rtx));
/* In regmove.c */ /* In regmove.c */
#ifdef BUFSIZ #ifdef BUFSIZ
......
...@@ -2729,9 +2729,9 @@ rest_of_compilation (decl) ...@@ -2729,9 +2729,9 @@ rest_of_compilation (decl)
if (rtl_dump_file) if (rtl_dump_file)
dump_flow_info (rtl_dump_file); dump_flow_info (rtl_dump_file);
delete_null_pointer_checks (insns); if (delete_null_pointer_checks (insns))
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP); cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
close_dump_file (DFI_null, print_rtl_with_bb, insns); close_dump_file (DFI_null, print_rtl_with_bb, insns);
} }
...@@ -2775,13 +2775,13 @@ rest_of_compilation (decl) ...@@ -2775,13 +2775,13 @@ rest_of_compilation (decl)
if (tem || optimize > 1) if (tem || optimize > 1)
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP); cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
/* Try to identify useless null pointer tests and delete them. */ /* Try to identify useless null pointer tests and delete them. */
if (flag_delete_null_pointer_checks || flag_thread_jumps) if (flag_delete_null_pointer_checks)
{ {
timevar_push (TV_JUMP); timevar_push (TV_JUMP);
if (flag_delete_null_pointer_checks) if (flag_delete_null_pointer_checks)
delete_null_pointer_checks (insns); if (delete_null_pointer_checks (insns))
/* CFG is no longer maintained up-to-date. */ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
timevar_pop (TV_JUMP); timevar_pop (TV_JUMP);
} }
...@@ -2814,7 +2814,6 @@ rest_of_compilation (decl) ...@@ -2814,7 +2814,6 @@ rest_of_compilation (decl)
timevar_push (TV_GCSE); timevar_push (TV_GCSE);
open_dump_file (DFI_gcse, decl); open_dump_file (DFI_gcse, decl);
cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
tem = gcse_main (insns, rtl_dump_file); tem = gcse_main (insns, rtl_dump_file);
rebuild_jump_labels (insns); rebuild_jump_labels (insns);
delete_trivially_dead_insns (insns, max_reg_num ()); delete_trivially_dead_insns (insns, max_reg_num ());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment