Commit 2402ffb6 by Richard Biener Committed by Richard Biener

re PR tree-optimization/82291 (wrong code at -O3 on x86_64-linux-gnu)

2017-09-22  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82291
	* tree-if-conv.c (predicate_mem_writes): Make sure to
	remove writes in blocks predicated with false.

	* gcc.dg/torture/pr82291.c: New testcase.

From-SVN: r253093
parent 2c818750
2017-09-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/82291
* tree-if-conv.c (predicate_mem_writes): Make sure to
remove writes in blocks predicated with false.
2017-09-22 Richard Biener <rguenther@suse.de>
* sese.c: Include cfganal.h.
(if_region_set_false_region): Remove.
(create_if_region_on_edge): Likewise.
2017-09-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/82291
* gcc.dg/torture/pr82291.c: New testcase.
2017-09-22 Sergey Shalnov <sergey.shalnov@intel.com>
* gcc.target/i386/avx512f-constant-set.c: New test.
......
/* { dg-do run } */
int a, c, d, *h;
unsigned b;
int *fn1 ()
{
int *f[3], g = 0;
for (; g < 3; g++)
f[g] = &a;
if (--b > a)
{
if (a > b)
d++;
return f[0];
}
}
void fn2 ()
{
for (; c >= 0; --c)
{
int j[] = { 0, 0, 0, 0, 0 };
int *k = fn1 ();
if (!k)
__builtin_abort ();
h = &j[4];
}
}
int main ()
{
fn2 ();
if (d != 0)
__builtin_abort ();
return 0;
}
......@@ -2197,7 +2197,7 @@ predicate_mem_writes (loop_p loop)
gimple *stmt;
int index;
if (is_true_predicate (cond) || is_false_predicate (cond))
if (is_true_predicate (cond))
continue;
swap = false;
......@@ -2210,9 +2210,17 @@ predicate_mem_writes (loop_p loop)
vect_sizes.truncate (0);
vect_masks.truncate (0);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
{
if (!gimple_assign_single_p (stmt = gsi_stmt (gsi)))
;
else if (is_false_predicate (cond))
{
unlink_stmt_vdef (stmt);
gsi_remove (&gsi, true);
release_defs (stmt);
continue;
}
else if (gimple_plf (stmt, GF_PLF_2))
{
tree lhs = gimple_assign_lhs (stmt);
......@@ -2301,6 +2309,8 @@ predicate_mem_writes (loop_p loop)
gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi));
update_stmt (stmt);
}
gsi_next (&gsi);
}
}
}
......
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