re PR rtl-optimization/89354 (Combine pass yields wrong code with -O2 and -msse2...
authorJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Feb 2019 23:10:47 +0000 (00:10 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Feb 2019 23:10:47 +0000 (00:10 +0100)
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: r268913

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

index e2c7b8ef3530f7a4db8ffba912e0007e02aef0f2..d3f970613933caf07acabd8c06f3bb2d801c5877 100644 (file)
@@ -1,6 +1,12 @@
+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.
+
 2019-02-14  Maya Rashish  <coypu@sdf.org>
 
-       * config.gcc (*-*-netbsd*): Add netbsd-d.o
+       * config.gcc (*-*-netbsd*): Add netbsd-d.o.
        * config/netbsd-d.c: New file.
        * config/t-netbsd: Add netbsd-d.o
 
index a24924816933affe25bb073f78a4bcfcd35295a6..91e32c88c8898781a884cb3b263855b88206cac7 100644 (file)
@@ -7830,6 +7830,10 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
       && partial_subreg_p (extraction_mode, mode))
     extraction_mode = mode;
 
+  /* Punt if len is too large for extraction_mode.  */
+  if (maybe_gt (len, GET_MODE_PRECISION (extraction_mode)))
+    return NULL_RTX;
+
   if (!MEM_P (inner))
     wanted_inner_mode = wanted_inner_reg_mode;
   else
index ae430692a128ca4dc742ac599d991697311dbacb..a08f401319729ae7f77dac99e1f7a3b0639cb28a 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/89354
+       * gcc.dg/pr89354.c: New test.
+
 2019-02-14  Uroš Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/ssse3-pabsb.c: Re-enable 64-bit form on AVX targets.
diff --git a/gcc/testsuite/gcc.dg/pr89354.c b/gcc/testsuite/gcc.dg/pr89354.c
new file mode 100644 (file)
index 0000000..0c58cc1
--- /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__((noipa)) static void
+foo (void)
+{
+  q = (q & ~0x1ffffffffULL) | 0x100000000ULL;
+}
+
+int
+main ()
+{
+  __asm volatile ("" : "+m" (q));
+  foo ();
+  if (q != 0x100000000ULL)
+    __builtin_abort ();
+  return 0;
+}