aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2004-01-12 17:32:12 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2004-01-12 16:32:12 +0000
commit432f982f5c2f65daa1d65a9af2fbfc585c88f114 (patch)
tree7bcdf745057a80c4e44eb2fff2033e874e50eea6
parent9a249c79b355459f3623cfbf8c0f2f6925d1a280 (diff)
downloadgcc-432f982f5c2f65daa1d65a9af2fbfc585c88f114.zip
gcc-432f982f5c2f65daa1d65a9af2fbfc585c88f114.tar.gz
gcc-432f982f5c2f65daa1d65a9af2fbfc585c88f114.tar.bz2
re PR rtl-optimization/12826 (Optimizer removes reference through volatile pointer)
PR opt/12826 * loop.c (insert_loop_mem): Preffer VOLATILE memory references to be stored. PR opt/12863 * cfgcleanup.c (label_is_jump_target_p): Move to... * rtlanal.c (label_is_jump_target_p): ... here. * cfgrtl.c (cfg_layout_redirect_edge_and_branch): Fix redirecting of fallthru edges unified with branch edges. From-SVN: r75733
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/cfgcleanup.c28
-rw-r--r--gcc/cfgrtl.c12
-rw-r--r--gcc/loop.c2
-rw-r--r--gcc/rtl.h1
-rw-r--r--gcc/rtlanal.c28
6 files changed, 53 insertions, 30 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3c7f1de..da3258f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2004-01-12 Jan Hubicka <jh@suse.cz>
+
+ PR opt/12826
+ * loop.c (insert_loop_mem): Preffer VOLATILE memory references to be
+ stored.
+
+ PR opt/12863
+ * cfgcleanup.c (label_is_jump_target_p): Move to...
+ * rtlanal.c (label_is_jump_target_p): ... here.
+ * cfgrtl.c (cfg_layout_redirect_edge_and_branch): Fix redirecting of fallthru
+ edges unified with branch edges.
+
2004-01-12 Richard Earnshaw <rearnsha@arm.com>
* simplify-rtx.c (simplify_immed_subreg): Correctly extract the
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 056a32f..3e68cbe 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -73,7 +73,6 @@ static bool outgoing_edges_match (int, basic_block, basic_block);
static int flow_find_cross_jump (int, basic_block, basic_block, rtx *, rtx *);
static bool insns_match_p (int, rtx, rtx);
-static bool label_is_jump_target_p (rtx, rtx);
static bool tail_recursion_label_p (rtx);
static void merge_blocks_move_predecessor_nojumps (basic_block, basic_block);
static void merge_blocks_move_successor_nojumps (basic_block, basic_block);
@@ -646,33 +645,6 @@ try_forward_edges (int mode, basic_block b)
return changed;
}
-/* Return true if LABEL is a target of JUMP_INSN. This applies only
- to non-complex jumps. That is, direct unconditional, conditional,
- and tablejumps, but not computed jumps or returns. It also does
- not apply to the fallthru case of a conditional jump. */
-
-static bool
-label_is_jump_target_p (rtx label, rtx jump_insn)
-{
- rtx tmp = JUMP_LABEL (jump_insn);
-
- if (label == tmp)
- return true;
-
- if (tablejump_p (jump_insn, NULL, &tmp))
- {
- rtvec vec = XVEC (PATTERN (tmp),
- GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC);
- int i, veclen = GET_NUM_ELEM (vec);
-
- for (i = 0; i < veclen; ++i)
- if (XEXP (RTVEC_ELT (vec, i), 0) == label)
- return true;
- }
-
- return false;
-}
-
/* Return true if LABEL is used for tail recursion. */
static bool
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index c44d252..7839d5b 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2463,10 +2463,18 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest)
{
/* Redirect any branch edges unified with the fallthru one. */
if (GET_CODE (BB_END (src)) == JUMP_INSN
- && JUMP_LABEL (BB_END (src)) == BB_HEAD (e->dest))
+ && label_is_jump_target_p (BB_HEAD (e->dest),
+ BB_END (src)))
{
- if (!redirect_jump (BB_END (src), block_label (dest), 0))
+ if (rtl_dump_file)
+ fprintf (rtl_dump_file, "Fallthru edge unified with branch "
+ "%i->%i redirected to %i\n",
+ e->src->index, e->dest->index, dest->index);
+ e->flags &= ~EDGE_FALLTHRU;
+ if (!redirect_branch_edge (e, dest))
abort ();
+ e->flags |= EDGE_FALLTHRU;
+ return true;
}
/* In case we are redirecting fallthru edge to the branch edge
of conditional jump, remove it. */
diff --git a/gcc/loop.c b/gcc/loop.c
index c0cf160..21369de 100644
--- a/gcc/loop.c
+++ b/gcc/loop.c
@@ -9561,6 +9561,8 @@ insert_loop_mem (rtx *mem, void *data ATTRIBUTE_UNUSED)
for (i = 0; i < loop_info->mems_idx; ++i)
if (rtx_equal_p (m, loop_info->mems[i].mem))
{
+ if (MEM_VOLATILE_P (m) && !MEM_VOLATILE_P (loop_info->mems[i].mem))
+ loop_info->mems[i].mem = m;
if (GET_MODE (m) != GET_MODE (loop_info->mems[i].mem))
/* The modes of the two memory accesses are different. If
this happens, something tricky is going on, and we just
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 7e42a1d..efd0e8b 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1725,6 +1725,7 @@ extern int insns_safe_to_move_p (rtx, rtx, rtx *);
extern int loc_mentioned_in_p (rtx *, rtx);
extern rtx find_first_parameter_load (rtx, rtx);
extern bool keep_with_call_p (rtx);
+extern bool label_is_jump_target_p (rtx, rtx);
/* flow.c */
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 059fe9e..15c4879 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -3709,3 +3709,31 @@ hoist_insn_to_edge (rtx insn, edge e, rtx val, rtx new)
end_sequence ();
return new_insn;
}
+
+/* Return true if LABEL is a target of JUMP_INSN. This applies only
+ to non-complex jumps. That is, direct unconditional, conditional,
+ and tablejumps, but not computed jumps or returns. It also does
+ not apply to the fallthru case of a conditional jump. */
+
+bool
+label_is_jump_target_p (rtx label, rtx jump_insn)
+{
+ rtx tmp = JUMP_LABEL (jump_insn);
+
+ if (label == tmp)
+ return true;
+
+ if (tablejump_p (jump_insn, NULL, &tmp))
+ {
+ rtvec vec = XVEC (PATTERN (tmp),
+ GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC);
+ int i, veclen = GET_NUM_ELEM (vec);
+
+ for (i = 0; i < veclen; ++i)
+ if (XEXP (RTVEC_ELT (vec, i), 0) == label)
+ return true;
+ }
+
+ return false;
+}
+