From: Kugan Vivekanandarajah Date: Mon, 6 Jun 2016 23:46:11 +0000 (+0000) Subject: re PR tree-optimization/71408 (wrong code at -Os and above on x86_64-linux-gnu) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ec963f2ae5a167060de578b72413ed4d870fe091;p=gcc.git re PR tree-optimization/71408 (wrong code at -Os and above on x86_64-linux-gnu) gcc/ChangeLog: 2016-06-07 Kugan Vivekanandarajah PR middle-end/71408 * tree-ssa-reassoc.c (zero_one_operation): Fix NEGATE_EXPR operand for propagate_op_to_single_use. gcc/testsuite/ChangeLog: 2016-06-07 Kugan Vivekanandarajah PR middle-end/71408 * gcc.dg/tree-ssa/pr71408.c: New test. From-SVN: r237158 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d586f9b3cf1..5e9ce57826b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-07 Kugan Vivekanandarajah + + PR middle-end/71408 + * tree-ssa-reassoc.c (zero_one_operation): Fix NEGATE_EXPR operand for + propagate_op_to_single_use. + 2016-06-07 Kugan Vivekanandarajah PR middle-end/71281 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 81d2fd52f1a..a1a7f1994ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-07 Kugan Vivekanandarajah + + PR middle-end/71408 + * gcc.dg/tree-ssa/pr71408.c: New test. + 2016-06-07 Kugan Vivekanandarajah PR middle-end/71281 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71408.c b/gcc/testsuite/gcc.dg/tree-ssa/pr71408.c new file mode 100644 index 00000000000..896a42869e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr71408.c @@ -0,0 +1,30 @@ +/* PR middle-end/71408 */ +/* { dg-do run } */ +/* { dg-options "-Os" } */ +unsigned a, b; + +struct S0 +{ + int f1:18; + unsigned f3:4; +}; + +void fn1 () +{ + struct S0 c = { 7, 0 }; + if (c.f1) + c.f3 = 3; + a = -~c.f3; + c.f3 = ~(c.f1 && c.f1); + c.f1 = c.f3 * (c.f1 - (c.f1 - a % c.f1)) + ~c.f3 * -a; + b = ~(c.f1 & a); + if (b >= 4294967295) + __builtin_abort (); +} + +int +main () +{ + fn1 (); + return 0; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 096b24dc1d3..36b34d37380 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1203,7 +1203,8 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op) { if (gimple_assign_rhs1 (stmt) == op) { - propagate_op_to_single_use (op, stmt, def); + tree cst = build_minus_one_cst (TREE_TYPE (op)); + propagate_op_to_single_use (cst, stmt, def); return; } else if (integer_minus_onep (op) @@ -1251,7 +1252,8 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op) { if (gimple_assign_rhs1 (stmt2) == op) { - propagate_op_to_single_use (op, stmt2, def); + tree cst = build_minus_one_cst (TREE_TYPE (op)); + propagate_op_to_single_use (cst, stmt2, def); return; } else if (integer_minus_onep (op)