]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/89195 (Corrupted stack offset after combine)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:38:28 +0000 (13:38 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:38:28 +0000 (13:38 +0200)
Backported from mainline
2019-02-05  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/89195
* combine.c (make_extraction): For MEMs, don't extract bytes outside
of the original MEM.

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

From-SVN: r275099

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr89195.c [new file with mode: 0644]

index 824bedc31707feaee5200a9feb8b1b5ae82a953c..ff921609067ce5be5c381cc5e0b4dcc5530a283a 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2019-02-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/89195
+       * combine.c (make_extraction): For MEMs, don't extract bytes outside
+       of the original MEM.
+
        PR target/89186
        * optabs.c (prepare_cmp_insn): Pass x and y to
        emit_block_comp_via_libcall rather than XEXP (x, 0) and XEXP (y, 0).
index 56f7f4912343fff019d1eb4716328ecf51d3237f..685b0db62e58d5d0415321a5a7e5acbaeb1867a4 100644 (file)
@@ -7481,6 +7481,7 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
              /* We can't do this if we are widening INNER_MODE (it
                 may not be aligned, for one thing).  */
              && GET_MODE_PRECISION (inner_mode) >= GET_MODE_PRECISION (tmode)
+             && pos + len <= GET_MODE_PRECISION (is_mode)
              && (inner_mode == tmode
                  || (! mode_dependent_address_p (XEXP (inner, 0),
                                                  MEM_ADDR_SPACE (inner))
index 8b5d6d16085a8249363d6d1c3ac965c0b60416cc..063fbdbca9512e34e3c5794d49c7fbf374d33695 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2019-02-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/89195
+       * gcc.c-torture/execute/pr89195.c: New test.
+
        PR target/89186
        * g++.dg/ext/vector36.C: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr89195.c b/gcc/testsuite/gcc.c-torture/execute/pr89195.c
new file mode 100644 (file)
index 0000000..017f5b4
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/89195 */
+/* { dg-require-effective-target int32plus } */
+
+struct S { unsigned i : 24; };
+
+volatile unsigned char x;
+
+__attribute__((noipa)) int
+foo (struct S d) 
+{
+  return d.i & x;
+}
+
+int
+main ()
+{
+  struct S d = { 0x123456 };
+  x = 0x75;
+  if (foo (d) != (0x56 & 0x75))
+    __builtin_abort ();
+  return 0;
+}