Commit 315adeda by Michael Matz Committed by Michael Matz

re PR rtl-optimization/42084 (Wrong result with -Os -fno-delete-null-pointer-checks)

        PR rtl-optimization/42084
        * cfgexpand.c (maybe_cleanup_end_of_block): Add new parameter,
        use it to stop walking.
        (expand_gimple_cond): Adjust call to above.

testsuite/
        * gcc.dg/pr42084.c: New test.

From-SVN: r154709
parent 67c330ae
2009-11-27 Michael Matz <matz@suse.de>
PR rtl-optimization/42084
* cfgexpand.c (maybe_cleanup_end_of_block): Add new parameter,
use it to stop walking.
(expand_gimple_cond): Adjust call to above.
2009-11-27 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2009-11-27 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/41810 PR target/41810
...@@ -1586,10 +1586,11 @@ label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED) ...@@ -1586,10 +1586,11 @@ label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED)
/* A subroutine of expand_gimple_cond. Given E, a fallthrough edge /* A subroutine of expand_gimple_cond. Given E, a fallthrough edge
of a basic block where we just expanded the conditional at the end, of a basic block where we just expanded the conditional at the end,
possibly clean up the CFG and instruction sequence. */ possibly clean up the CFG and instruction sequence. LAST is the
last instruction before the just emitted jump sequence. */
static void static void
maybe_cleanup_end_of_block (edge e) maybe_cleanup_end_of_block (edge e, rtx last)
{ {
/* Special case: when jumpif decides that the condition is /* Special case: when jumpif decides that the condition is
trivial it emits an unconditional jump (and the necessary trivial it emits an unconditional jump (and the necessary
...@@ -1604,7 +1605,6 @@ maybe_cleanup_end_of_block (edge e) ...@@ -1604,7 +1605,6 @@ maybe_cleanup_end_of_block (edge e)
normally isn't there in a cleaned CFG), fix it here. */ normally isn't there in a cleaned CFG), fix it here. */
if (BARRIER_P (get_last_insn ())) if (BARRIER_P (get_last_insn ()))
{ {
basic_block bb = e->src;
rtx insn; rtx insn;
remove_edge (e); remove_edge (e);
/* Now, we have a single successor block, if we have insns to /* Now, we have a single successor block, if we have insns to
...@@ -1620,7 +1620,7 @@ maybe_cleanup_end_of_block (edge e) ...@@ -1620,7 +1620,7 @@ maybe_cleanup_end_of_block (edge e)
/* Make sure we have an unconditional jump. Otherwise we're /* Make sure we have an unconditional jump. Otherwise we're
confused. */ confused. */
gcc_assert (JUMP_P (insn) && !any_condjump_p (insn)); gcc_assert (JUMP_P (insn) && !any_condjump_p (insn));
for (insn = PREV_INSN (insn); insn != BB_HEAD (bb);) for (insn = PREV_INSN (insn); insn != last;)
{ {
insn = PREV_INSN (insn); insn = PREV_INSN (insn);
if (JUMP_P (NEXT_INSN (insn))) if (JUMP_P (NEXT_INSN (insn)))
...@@ -1699,7 +1699,7 @@ expand_gimple_cond (basic_block bb, gimple stmt) ...@@ -1699,7 +1699,7 @@ expand_gimple_cond (basic_block bb, gimple stmt)
} }
true_edge->goto_block = NULL; true_edge->goto_block = NULL;
false_edge->flags |= EDGE_FALLTHRU; false_edge->flags |= EDGE_FALLTHRU;
maybe_cleanup_end_of_block (false_edge); maybe_cleanup_end_of_block (false_edge, last);
return NULL; return NULL;
} }
if (true_edge->dest == bb->next_bb) if (true_edge->dest == bb->next_bb)
...@@ -1715,7 +1715,7 @@ expand_gimple_cond (basic_block bb, gimple stmt) ...@@ -1715,7 +1715,7 @@ expand_gimple_cond (basic_block bb, gimple stmt)
} }
false_edge->goto_block = NULL; false_edge->goto_block = NULL;
true_edge->flags |= EDGE_FALLTHRU; true_edge->flags |= EDGE_FALLTHRU;
maybe_cleanup_end_of_block (true_edge); maybe_cleanup_end_of_block (true_edge, last);
return NULL; return NULL;
} }
......
2009-11-27 Michael Matz <matz@suse.de> 2009-11-27 Michael Matz <matz@suse.de>
PR rtl-optimization/42084
* gcc.dg/pr42084.c: New test.
2009-11-27 Michael Matz <matz@suse.de>
PR c++/41906 PR c++/41906
* g++.dg/tree-ssa/pr41906.C: New testcase. * g++.dg/tree-ssa/pr41906.C: New testcase.
......
/* { dg-do run } */
/* { dg-options "-O1 -fno-delete-null-pointer-checks" } */
extern void abort (void);
int g = 0;
static int __attribute__((noinline)) f (long long a, long long b)
{
int cmp;
cmp = a > b;
if (&g == 0)
cmp-=2;
else
cmp++;
return cmp;
}
int main (void)
{
int ret = f (2, 1);
if (ret != 2)
abort ();
return 0;
}
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