From: Richard Biener Date: Mon, 28 Nov 2016 15:03:55 +0000 (+0000) Subject: re PR tree-optimization/78542 (wrong code at -Og results in endless loop) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6522add29b65f7fe572202b2a1e83a8cd00b07fa;p=gcc.git re PR tree-optimization/78542 (wrong code at -Og results in endless loop) 2016-11-28 Richard Biener PR tree-optimization/78542 * tree-ssa-ccp.c (evaluate_stmt): Only valueize simplification if allowed. * gcc.dg/torture/pr78542.c: New testcase. From-SVN: r242920 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 83615edeeb2..15129d98b53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-28 Richard Biener + + PR tree-optimization/78542 + * tree-ssa-ccp.c (evaluate_stmt): Only valueize simplification + if allowed. + 2016-11-28 Paolo Bonzini * combine.c (simplify_if_then_else): Simplify IF_THEN_ELSE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0374608b554..8535df42f0c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-28 Richard Biener + + PR tree-optimization/78542 + * gcc.dg/torture/pr78542.c: New testcase. + 2016-11-28 Richard Biener PR tree-optimization/78343 diff --git a/gcc/testsuite/gcc.dg/torture/pr78542.c b/gcc/testsuite/gcc.dg/torture/pr78542.c new file mode 100644 index 00000000000..bae42b65333 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr78542.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef unsigned V __attribute__ ((vector_size (16))); + +V +foo (unsigned x, V v) +{ + do { + v %= x; + x = 1; + } while (v[1]); + return v; +} + +int +main () +{ + V x = foo (5, (V) { 0, 1 }); + if (x[0] || x[1] || x[2] || x[3]) + __builtin_abort(); + return 0; +} diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index f89da708f42..084b2e1dace 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1744,7 +1744,12 @@ evaluate_stmt (gimple *stmt) { fold_defer_overflow_warnings (); simplified = ccp_fold (stmt); - if (simplified && TREE_CODE (simplified) == SSA_NAME) + if (simplified + && TREE_CODE (simplified) == SSA_NAME + /* We may not use values of something that may be simulated again, + see valueize_op_1. */ + && (SSA_NAME_IS_DEFAULT_DEF (simplified) + || ! prop_simulate_again_p (SSA_NAME_DEF_STMT (simplified)))) { ccp_prop_value_t *val = get_value (simplified); if (val && val->lattice_val != VARYING)