PR tree-optimization/78162: Reject negative offsets in store merging early
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Wed, 2 Nov 2016 09:25:22 +0000 (09:25 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Wed, 2 Nov 2016 09:25:22 +0000 (09:25 +0000)
PR tree-optimization/78162
* gimple-ssa-store-merging.c (execute): Mark stores with bitpos < 0
as invalid.

* gcc.c-torture/compile/pr78162.c: New test.

From-SVN: r241778

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

index 52215f6eebf107833f6bc5f1a28614dc8158e3a2..aee2b83f8b3acfd6ea33e2156b4b22521aaf8fd4 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR tree-optimization/78162
+       * gimple-ssa-store-merging.c (execute): Mark stores with bitpos < 0
+       as invalid.
+
 2016-11-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/aarch64/aarch64.c (aarch64_register_saved_on_entry): Add
index 97af1418c978093044ab9cb859eb7b6c249873ce..feba907559f766a9cbedb9dcf9c933bc0acc84a5 100644 (file)
@@ -1361,7 +1361,7 @@ pass_store_merging::execute (function *fun)
                                       &unsignedp, &reversep, &volatilep);
              /* As a future enhancement we could handle stores with the same
                 base and offset.  */
-             bool invalid = offset || reversep
+             bool invalid = offset || reversep || bitpos < 0
                             || ((bitsize > MAX_BITSIZE_MODE_ANY_INT)
                                  && (TREE_CODE (rhs) != INTEGER_CST))
                             || !rhs_valid_for_store_merging_p (rhs)
index 6827c0090bcb00d1767215db6c096930895d5794..d979a56fcf7525530a497c7266d3ccff4f51bb5a 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR tree-optimization/78162
+       * gcc.c-torture/compile/pr78162.c: New test.
+
 2016-11-02  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78035
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78162.c b/gcc/testsuite/gcc.c-torture/compile/pr78162.c
new file mode 100644 (file)
index 0000000..743d4e6
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR tree-optimization/78162.
+   Handle negative offsets in store merging gracefully.  */
+
+int a, b[1][2];
+
+void fn1()
+{
+  for (a = 0; a < 2; a++)
+    b[-1][a] = 0;
+}