[rtlanal] Fix rtl-optimization/71295
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 2 Jun 2016 12:26:42 +0000 (12:26 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Thu, 2 Jun 2016 12:26:42 +0000 (12:26 +0000)
PR rtl-optimization/71295
* rtlanal.c (subreg_get_info): If taking a subreg at the requested
offset would go over the size of the inner mode reject it.

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

From-SVN: r237034

gcc/ChangeLog
gcc/rtlanal.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr71295.c [new file with mode: 0644]

index 6c983ac1df1d448f972d4ea0f607a4cbcb02750c..01beb954298220db06cabec47ab3247c753ad83f 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/71295
+       * rtlanal.c (subreg_get_info): If taking a subreg at the requested
+       offset would go over the size of the inner mode reject it.
+
 2016-06-02  Jakub Jelinek  <jakub@redhat.com>
 
        * config/i386/sse.md (*vec_concatv4si): Use v=v,v instead of
index 0b6e1e0e38d18f76a92ddbd43c45f938b0144fe8..8e4762c86817adff665d5e5b5e4d54a3ed63e7ff 100644 (file)
@@ -3657,6 +3657,16 @@ subreg_get_info (unsigned int xregno, machine_mode xmode,
          info->offset = offset / regsize_xmode;
          return;
        }
+      /* It's not valid to extract a subreg of mode YMODE at OFFSET that
+        would go outside of XMODE.  */
+      if (!rknown
+         && GET_MODE_SIZE (ymode) + offset > GET_MODE_SIZE (xmode))
+       {
+         info->representable_p = false;
+         info->nregs = nregs_ymode;
+         info->offset = offset / regsize_xmode;
+         return;
+       }
       /* Quick exit for the simple and common case of extracting whole
         subregisters from a multiregister value.  */
       /* ??? It would be better to integrate this into the code below,
index c4b2f2510a4f5659e3fc501a6fe928b28ff9d125..2bd4681100453bcc5c4747f03d13f0f1fa2bff39 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/71295
+       * gcc.c-torture/compile/pr71295.c: New test.
+
 2016-06-02  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.target/i386/avx512vl-concatv4si-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr71295.c b/gcc/testsuite/gcc.c-torture/compile/pr71295.c
new file mode 100644 (file)
index 0000000..d2ec852
--- /dev/null
@@ -0,0 +1,12 @@
+extern void fn2 (long long);
+int a;
+
+void
+fn1 ()
+{
+  long long b[3];
+  a = 0;
+  for (; a < 3; a++)
+    b[a] = 1;
+  fn2 (b[1]);
+}