re PR rtl-optimization/89195 (Corrupted stack offset after combine)
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Feb 2019 15:38:57 +0000 (16:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Feb 2019 15:38:57 +0000 (16:38 +0100)
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: r268542

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

index a6c7f8c6c7a0fb77d2b61fc4c7e8e47ecae7a0ae..c3340dbaf4085dce6599e1118fc98fe5e99b7e18 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2019-02-05  Martin Liska  <mliska@suse.cz>
 
        PR gcov-profile/89000
index 7e1992f866f5247a9931519d152b256e5b65a609..a24924816933affe25bb073f78a4bcfcd35295a6 100644 (file)
@@ -7687,6 +7687,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).  */
              && !paradoxical_subreg_p (tmode, inner_mode)
+             && known_le (pos + len, GET_MODE_PRECISION (is_mode))
              && (inner_mode == tmode
                  || (! mode_dependent_address_p (XEXP (inner, 0),
                                                  MEM_ADDR_SPACE (inner))
index 9036622155510b4f43bdb9e49f2c960dc0137ebb..b232907be17c2925ffaabcbe134baff8449ff3a8 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/89195
+       * gcc.c-torture/execute/pr89195.c: New test.
+
 2019-02-05  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        * gcc.target/powerpc/vec-extract-slong-1.c: Require p8 execution
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;
+}