re PR tree-optimization/86066 (wrong code for bit-field manipulation at -Os)
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 6 Jun 2018 13:13:24 +0000 (13:13 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 6 Jun 2018 13:13:24 +0000 (13:13 +0000)
PR tree-optimization/86066
* gimple-ssa-store-merging.c (process_store): Do not bypass BIT_NOT_EXPR
for BIT_INSERT_EXPR stores.

From-SVN: r261232

gcc/ChangeLog
gcc/gimple-ssa-store-merging.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr86066.c [new file with mode: 0644]

index 18280e8a0410db00324a6e36a4da577b904d5f15..bda6ed466f84180c4a6bd9cafb36a23f8045b40c 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR tree-optimization/86066
+       * gimple-ssa-store-merging.c (process_store): Do not bypass BIT_NOT_EXPR
+       for BIT_INSERT_EXPR stores.
+
 2018-06-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/86062
index 1cefdeb69b8347d93015a39a89e3489b1ee84d7d..007419bfe61ea425786fc2123e045b44d9cefa56 100644 (file)
@@ -4333,7 +4333,9 @@ pass_store_merging::process_store (gimple *stmt)
          && const_bitsize <= 64)
        {
          /* Bypass a conversion to the bit-field type.  */
-         if (is_gimple_assign (def_stmt) && CONVERT_EXPR_CODE_P (rhs_code))
+         if (!bit_not_p
+             && is_gimple_assign (def_stmt)
+             && CONVERT_EXPR_CODE_P (rhs_code))
            {
              tree rhs1 = gimple_assign_rhs1 (def_stmt);
              if (TREE_CODE (rhs1) == SSA_NAME
@@ -4341,6 +4343,7 @@ pass_store_merging::process_store (gimple *stmt)
                rhs = rhs1;
            }
          rhs_code = BIT_INSERT_EXPR;
+         bit_not_p = false;
          ops[0].val = rhs;
          ops[0].base_addr = NULL_TREE;
          ops[1].base_addr = NULL_TREE;
index 095cae3f972dd3853e5d4ba156609d9bd938a963..f63c9d75a8c35a9033cb58e98c3342268325af14 100644 (file)
@@ -1,3 +1,7 @@
+2018-06-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/torture/pr86066.c: New test.
+
 2018-06-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/86062
diff --git a/gcc/testsuite/gcc.dg/torture/pr86066.c b/gcc/testsuite/gcc.dg/torture/pr86066.c
new file mode 100644 (file)
index 0000000..9127ed3
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/86066 */
+/* Testcase by Zhendong Su <Zhendong Su> */
+
+struct A
+{
+  int b:2;
+  int c:2;
+  unsigned d:8;
+};
+
+int main ()
+{
+  struct A t = { 0, 0, 2 };
+ L:
+  t.d = ~(~(~0 % t.d) % 2);
+  if (!t.d)
+    goto L;
+  return 0;
+}