re PR tree-optimization/71408 (wrong code at -Os and above on x86_64-linux-gnu)
authorKugan Vivekanandarajah <kuganv@linaro.org>
Mon, 6 Jun 2016 23:46:11 +0000 (23:46 +0000)
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>
Mon, 6 Jun 2016 23:46:11 +0000 (23:46 +0000)
gcc/ChangeLog:

2016-06-07  Kugan Vivekanandarajah  <kuganv@linaro.org>

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  <kuganv@linaro.org>

PR middle-end/71408
* gcc.dg/tree-ssa/pr71408.c: New test.

From-SVN: r237158

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr71408.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index d586f9b3cf1c32e11ec7c3de4ec71dd43f3fba76..5e9ce57826b0348ca585cc2bdaa001451c14b85c 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-07  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       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  <kuganv@linaro.org>
 
        PR middle-end/71281
index 81d2fd52f1a2dfb2b334edd7bc791b222dfbf834..a1a7f1994ffe48b028621ec202e50e857401d112 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-07  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       PR middle-end/71408
+       * gcc.dg/tree-ssa/pr71408.c: New test.
+
 2016-06-07  Kugan Vivekanandarajah  <kuganv@linaro.org>
 
        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 (file)
index 0000000..896a428
--- /dev/null
@@ -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;
+}
index 096b24dc1d37d45cc9925b08f9fe38bff49309ec..36b34d37380628a3bc825eba7881973c3dfd4a81 100644 (file)
@@ -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)