aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@gcc.gnu.org>2001-07-29 17:01:53 +0000
committerJan Hubicka <hubicka@gcc.gnu.org>2001-07-29 17:01:53 +0000
commit0068fd9637aa304ba7b27d720719bd589a7755ce (patch)
treeea95e3e09027651222c04624fd31922365dd2cc8 /gcc
parentdf07e07d1a0f83cc18efc5f901dfd4fb262d538a (diff)
downloadgcc-0068fd9637aa304ba7b27d720719bd589a7755ce.zip
gcc-0068fd9637aa304ba7b27d720719bd589a7755ce.tar.gz
gcc-0068fd9637aa304ba7b27d720719bd589a7755ce.tar.bz2
basic-block.h (CLEANUP_PRE_LOOP): New.
* basic-block.h (CLEANUP_PRE_LOOP): New. * except.c (finish_eh_generation): Update call of cleanup_cfg. * sibcall.c (optimize_sibling_calls): Likewise. * toplev.c (rest_of_compilation): Likewise. * flow.c (try_forward_edges): Take argument MODE; do not forward over loop pre-headers if CLEANUP_PRE_LOOP. (try_optimize_cfg): Update call of try_forward_edges. * (validate_replace_rtx_1): Fix simplification of MINUS. From-SVN: r44458
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/basic-block.h2
-rw-r--r--gcc/except.c4
-rw-r--r--gcc/flow.c31
-rw-r--r--gcc/recog.c4
-rw-r--r--gcc/sibcall.c2
-rw-r--r--gcc/toplev.c16
7 files changed, 58 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4a0fdff..aa26118 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+Sun Jul 29 18:59:13 CEST 2001 Jan Hubicka <jh@suse.cz>
+
+ * basic-block.h (CLEANUP_PRE_LOOP): New.
+ * except.c (finish_eh_generation): Update call of cleanup_cfg.
+ * sibcall.c (optimize_sibling_calls): Likewise.
+ * toplev.c (rest_of_compilation): Likewise.
+ * flow.c (try_forward_edges): Take argument MODE;
+ do not forward over loop pre-headers if CLEANUP_PRE_LOOP.
+ (try_optimize_cfg): Update call of try_forward_edges.
+
+Sun Jul 29 18:59:56 CEST 2001 Roman Zippel <zippel@linux-m68k.org>
+ Jan Hubicka <jh@suse.cz>
+
+ * (validate_replace_rtx_1): Fix simplification of MINUS.
+
2001-07-29 Neil Booth <neil@daikokuya.demon.co.uk>
PR preprocessor/3669
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index bddba84..7b467c2 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -551,6 +551,8 @@ enum update_life_extent
to care REG_DEAD notes. */
#define CLEANUP_PRE_SIBCALL 8 /* Do not get confused by code hidden
inside call_placeholders.. */
+#define CLEANUP_PRE_LOOP 16 /* Take care to preserve syntactic loop
+ notes. */
/* Flags for loop discovery. */
#define LOOP_TREE 1 /* Build loop hierarchy tree. */
diff --git a/gcc/except.c b/gcc/except.c
index b45237c..49df0df 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -2348,7 +2348,7 @@ finish_eh_generation ()
rebuild_jump_labels (get_insns ());
find_basic_blocks (get_insns (), max_reg_num (), 0);
- cleanup_cfg (0);
+ cleanup_cfg (CLEANUP_PRE_LOOP);
/* These registers are used by the landing pads. Make sure they
have been generated. */
@@ -2371,7 +2371,7 @@ finish_eh_generation ()
find_exception_handler_labels ();
rebuild_jump_labels (get_insns ());
find_basic_blocks (get_insns (), max_reg_num (), 0);
- cleanup_cfg (0);
+ cleanup_cfg (CLEANUP_PRE_LOOP);
}
/* This section handles removing dead code for flow. */
diff --git a/gcc/flow.c b/gcc/flow.c
index 0fd58c0..992cac6 100644
--- a/gcc/flow.c
+++ b/gcc/flow.c
@@ -396,7 +396,7 @@ static bool try_optimize_cfg PARAMS ((int));
static bool can_fallthru PARAMS ((basic_block, basic_block));
static bool try_redirect_by_replacing_jump PARAMS ((edge, basic_block));
static bool try_simplify_condjump PARAMS ((basic_block));
-static bool try_forward_edges PARAMS ((basic_block));
+static bool try_forward_edges PARAMS ((int, basic_block));
static void tidy_fallthru_edges PARAMS ((void));
static int verify_wide_reg_1 PARAMS ((rtx *, void *));
static void verify_wide_reg PARAMS ((int, rtx, rtx));
@@ -3182,8 +3182,9 @@ try_simplify_condjump (cbranch_block)
Return true if sucessful. */
static bool
-try_forward_edges (b)
+try_forward_edges (mode, b)
basic_block b;
+ int mode;
{
bool changed = false;
edge e, next;
@@ -3216,6 +3217,30 @@ try_forward_edges (b)
/* Bypass trivial infinite loops. */
if (target == target->succ->dest)
counter = n_basic_blocks;
+
+ /* Avoid killing of loop pre-headers, as it is the place loop
+ optimizer wants to hoist code to.
+
+ For fallthru forwarders, the LOOP_BEG note must appear between
+ the header of block and CODE_LABEL of the loop, for non forwarders
+ it must appear before the JUMP_INSN. */
+ if (mode & CLEANUP_PRE_LOOP)
+ {
+ rtx insn = (target->succ->flags & EDGE_FALLTHRU
+ ? target->head : prev_nonnote_insn (target->end));
+
+ if (GET_CODE (insn) != NOTE)
+ insn = NEXT_INSN (insn);
+
+ for (;insn && GET_CODE (insn) != CODE_LABEL && !INSN_P (insn);
+ insn = NEXT_INSN (insn))
+ if (GET_CODE (insn) == NOTE
+ && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
+ break;
+
+ if (GET_CODE (insn) == NOTE)
+ break;
+ }
target = target->succ->dest, counter++;
}
@@ -3953,7 +3978,7 @@ try_optimize_cfg (mode)
changed_here = true;
/* Simplify branch to branch. */
- if (try_forward_edges (b))
+ if (try_forward_edges (mode, b))
changed_here = true;
/* Look for shared code between blocks. */
diff --git a/gcc/recog.c b/gcc/recog.c
index c77bc42..fc349dd 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -521,8 +521,8 @@ validate_replace_rtx_1 (loc, from, to, object)
simplify_gen_binary
(PLUS, GET_MODE (x), XEXP (x, 0),
simplify_gen_unary (NEG,
- op0_mode, XEXP (x, 1),
- op0_mode)), 1);
+ GET_MODE (x), XEXP (x, 1),
+ GET_MODE (x))), 1);
break;
case ZERO_EXTEND:
case SIGN_EXTEND:
diff --git a/gcc/sibcall.c b/gcc/sibcall.c
index 1203e68..1e3be76 100644
--- a/gcc/sibcall.c
+++ b/gcc/sibcall.c
@@ -569,7 +569,7 @@ optimize_sibling_and_tail_recursive_calls ()
/* We need cfg information to determine which blocks are succeeded
only by the epilogue. */
find_basic_blocks (insns, max_reg_num (), 0);
- cleanup_cfg (CLEANUP_PRE_SIBCALL);
+ cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
/* If there are no basic blocks, then there is nothing to do. */
if (n_basic_blocks == 0)
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 21d4fbb..07de29b 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2737,7 +2737,7 @@ rest_of_compilation (decl)
rebuild_jump_labels (insns);
find_exception_handler_labels ();
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_PRE_SIBCALL);
+ cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
optimize = saved_optimize;
}
@@ -2846,7 +2846,7 @@ rest_of_compilation (decl)
reg_scan (insns, max_reg_num (), 0);
rebuild_jump_labels (insns);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
+ cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP);
copy_loop_headers (insns);
purge_line_number_notes (insns);
@@ -2870,7 +2870,7 @@ rest_of_compilation (decl)
open_dump_file (DFI_ssa, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_EXPENSIVE);
+ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
convert_to_ssa ();
close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
@@ -2935,7 +2935,7 @@ rest_of_compilation (decl)
if (optimize > 0)
{
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_EXPENSIVE);
+ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
/* ??? Run if-conversion before delete_null_pointer_checks,
since the later does not preserve the CFG. This should
@@ -2992,7 +2992,7 @@ rest_of_compilation (decl)
timevar_push (TV_JUMP);
rebuild_jump_labels (insns);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_EXPENSIVE);
+ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
timevar_pop (TV_JUMP);
}
@@ -3006,7 +3006,7 @@ rest_of_compilation (decl)
timevar_push (TV_JUMP);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_EXPENSIVE);
+ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
delete_null_pointer_checks (insns);
timevar_pop (TV_JUMP);
@@ -3040,7 +3040,7 @@ rest_of_compilation (decl)
open_dump_file (DFI_gcse, decl);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_EXPENSIVE);
+ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
tem = gcse_main (insns, rtl_dump_file);
save_csb = flag_cse_skip_blocks;
@@ -3067,7 +3067,7 @@ rest_of_compilation (decl)
rebuild_jump_labels (insns);
delete_trivially_dead_insns (insns, max_reg_num (), 0);
find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
- cleanup_cfg (CLEANUP_EXPENSIVE);
+ cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
timevar_pop (TV_JUMP);
if (flag_expensive_optimizations)