]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/89354 (Combine pass yields wrong code with -O2 and...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:59:10 +0000 (13:59 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:59:10 +0000 (13:59 +0200)
Backported from mainline
2019-02-14  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/89354
* combine.c (make_extraction): Punt if extraction_mode is narrower
than len bits.

* gcc.dg/pr89354.c: New test.

From-SVN: r275111

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr89354.c [new file with mode: 0644]

index b0acf9e48fe0dc6386b4b3d1b27a3a362e9392e7..2d31992d9bac248e36b5c17ca5690e613120b475 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2019-02-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/89354
+       * combine.c (make_extraction): Punt if extraction_mode is narrower
+       than len bits.
+
        PR tree-optimization/89314
        * fold-const.c (fold_binary_loc): Cast strlen argument to
        const char * before dereferencing it.  Formatting fixes.
index ee4f1e19c45b49ae24952779c0e311b7b504df4e..7e9aedb002033dfb3566ca0e700bf18c54e81fcf 100644 (file)
@@ -7638,6 +7638,10 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
       && GET_MODE_SIZE (extraction_mode) < GET_MODE_SIZE (mode))
     extraction_mode = mode;
 
+  /* Punt if len is too large for extraction_mode.  */
+  if (len > GET_MODE_PRECISION (extraction_mode))
+    return NULL_RTX;
+
   if (!MEM_P (inner))
     wanted_inner_mode = wanted_inner_reg_mode;
   else
index 1a02952c35b25ff54e5cc293c17c55e9113a9d08..57e6aa69d90dd81fdd2d913e1341850443f590c8 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2019-02-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/89354
+       * gcc.dg/pr89354.c: New test.
+
        PR tree-optimization/89314
        * gcc.dg/pr89314.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr89354.c b/gcc/testsuite/gcc.dg/pr89354.c
new file mode 100644 (file)
index 0000000..85ad52a
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/89354 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+
+static unsigned long long q = 0;
+
+__attribute__((noinline, noclone)) static void
+foo (void)
+{
+  q = (q & ~0x1ffffffffULL) | 0x100000000ULL;
+}
+
+int
+main ()
+{
+  __asm volatile ("" : "+m" (q));
+  foo ();
+  if (q != 0x100000000ULL)
+    __builtin_abort ();
+  return 0;
+}