re PR tree-optimization/82954 (ICE in fold_binary_loc, at fold-const.c:9061)
authorJakub Jelinek <jakub@redhat.com>
Mon, 13 Nov 2017 09:01:24 +0000 (10:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 13 Nov 2017 09:01:24 +0000 (10:01 +0100)
PR tree-optimization/82954
* gimple-ssa-store-merging.c
(imm_store_chain_info::coalesce_immediate_stores): If
!infof->ops[N].base_addr, split group if info->ops[N].base_addr.

* gcc.c-torture/execute/pr82954.c: New test.

From-SVN: r254671

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

index dce8e02ba80750e66fa59187ae062917052d3263..293f584682f3fabd06c2e98b7fd83bd39e3cd7ee 100644 (file)
@@ -1,3 +1,10 @@
+2017-11-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/82954
+       * gimple-ssa-store-merging.c
+       (imm_store_chain_info::coalesce_immediate_stores): If
+       !infof->ops[N].base_addr, split group if info->ops[N].base_addr.
+
 2017-11-13  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * config/aarch64/aarch64-simd.md (aarch64_store_lane0<mode>):
index 40f7c9843f643826898376ea0f76551275aa8780..54cb86e4cc7b02d4756ab9f9a1e50a608026d574 100644 (file)
@@ -1198,10 +1198,12 @@ imm_store_chain_info::coalesce_immediate_stores ()
              std::swap (info->ops[0], info->ops[1]);
              info->ops_swapped_p = true;
            }
-         if ((!infof->ops[0].base_addr
-              || compatible_load_p (merged_store, info, base_addr, 0))
-             && (!infof->ops[1].base_addr
-                 || compatible_load_p (merged_store, info, base_addr, 1)))
+         if ((infof->ops[0].base_addr
+              ? compatible_load_p (merged_store, info, base_addr, 0)
+              : !info->ops[0].base_addr)
+             && (infof->ops[1].base_addr
+                 ? compatible_load_p (merged_store, info, base_addr, 1)
+                 : !info->ops[1].base_addr))
            {
              merged_store->merge_into (info);
              continue;
index 4c739572756e98b2cd461fe74d1eaac44508f72e..fc943c191266e276274b2f616bdeb61254230147 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/82954
+       * gcc.c-torture/execute/pr82954.c: New test.
+
 2017-11-11  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/82932
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr82954.c b/gcc/testsuite/gcc.c-torture/execute/pr82954.c
new file mode 100644 (file)
index 0000000..5ced285
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR tree-optimization/82954 */
+
+__attribute__((noipa)) void
+foo (int *__restrict p, int *__restrict q)
+{
+  p[0] = p[0] ^ 1;
+  p[1] = p[1] ^ 2;
+  p[2] = p[2] ^ q[2];
+  p[3] = p[3] ^ q[3];
+}
+
+int
+main ()
+{
+  int p[4] = { 16, 32, 64, 128 };
+  int q[4] = { 8, 4, 2, 1 };
+  asm volatile ("" : : "g" (p), "g" (q) : "memory");
+  foo (p, q);
+  if (p[0] != 17 || p[1] != 34 || p[2] != 66 || p[3] != 129)
+    __builtin_abort ();
+  return 0;
+}