Commit 8a18fcf4 by Yuri Rumyantsev Committed by Ilya Enkovich

PR tree-optimization/67909, 67947

gcc/

2014-10-13  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR tree-optimization/67909, 67947
	* tree-ssa-loop-unswitch.c (find_loop_guard): Add check that GUARD_EDGE
	really skip the inner loop.

gcc/testsuite/

2014-10-13  Yuri Rumyantsev  <ysrumyan@gmail.com>

	PR tree-optimization/67909, 67947
	* gcc.dg/torture/pr67947.c: New test.

From-SVN: r228760
parent 92a1d1e1
2014-10-13 Yuri Rumyantsev <ysrumyan@gmail.com>
PR tree-optimization/67909, 67947
* tree-ssa-loop-unswitch.c (find_loop_guard): Add check that GUARD_EDGE
really skip the inner loop.
2015-10-13 Jeff Law <law@redhat.com> 2015-10-13 Jeff Law <law@redhat.com>
* tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths): * tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
2014-10-13 Yuri Rumyantsev <ysrumyan@gmail.com>
PR tree-optimization/67909, 67947
* gcc.dg/torture/pr67947.c: New test.
2015-10-13 Jeff Law <law@redhat.com> 2015-10-13 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-thread-13.c: New test. * gcc.dg/tree-ssa/ssa-thread-13.c: New test.
......
/* { dg-additional-options "-O3" } */
#include <stdlib.h>
int a;
int c;
__attribute__((noinline, noclone)) void foo (int x)
{
if (x == 0)
c++;
}
int
main (int argc, char* argv[])
{
int j, k, b = 0;
if (argc == 0)
b = 1;
for (j = 0; j < 3; j++)
for (k = 0; k < 1; k++)
{
foo (0);
if (b)
for (k = -1; a;)
;
}
if (c != 3)
abort ();
return 0;
}
...@@ -471,7 +471,6 @@ find_loop_guard (struct loop *loop) ...@@ -471,7 +471,6 @@ find_loop_guard (struct loop *loop)
{ {
basic_block header = loop->header; basic_block header = loop->header;
edge guard_edge, te, fe; edge guard_edge, te, fe;
/* bitmap processed, known_invariants;*/
basic_block *body = NULL; basic_block *body = NULL;
unsigned i; unsigned i;
tree use; tree use;
...@@ -529,6 +528,16 @@ find_loop_guard (struct loop *loop) ...@@ -529,6 +528,16 @@ find_loop_guard (struct loop *loop)
else else
return NULL; return NULL;
/* Guard edge must skip inner loop. */
if (!dominated_by_p (CDI_DOMINATORS, loop->inner->header,
guard_edge == fe ? te->dest : fe->dest))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Guard edge %d --> %d is not around the loop!\n",
guard_edge->src->index, guard_edge->dest->index);
return NULL;
}
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, fprintf (dump_file,
"Considering guard %d -> %d in loop %d\n", "Considering guard %d -> %d in loop %d\n",
......
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