re PR target/69071 (ICE: in decompose, at rtl.h:2107 with -g)
authorJakub Jelinek <jakub@redhat.com>
Mon, 11 Jan 2016 19:06:34 +0000 (20:06 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 11 Jan 2016 19:06:34 +0000 (20:06 +0100)
PR target/69071
* lra-eliminations.c (move_plus_up): Only move plus up
if subreg of the constant can be simplified into constant
and use the simplified subreg of the constant instead of
the original constant.

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

From-SVN: r232241

gcc/ChangeLog
gcc/lra-eliminations.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr69071.c [new file with mode: 0644]

index 5936b42..3d05c57 100644 (file)
@@ -1,5 +1,11 @@
 2016-01-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/69071
+       * lra-eliminations.c (move_plus_up): Only move plus up
+       if subreg of the constant can be simplified into constant
+       and use the simplified subreg of the constant instead of
+       the original constant.
+
        * fold-const.c (fold_convertible_p): Don't return true
        for conversion of VECTOR_TYPE to same sized integral type.
        (fold_convert_loc): Fix up formatting.  Fold conversion of
index ec9d7b7..99d5c6f 100644 (file)
@@ -296,9 +296,14 @@ move_plus_up (rtx x)
   if (GET_CODE (x) == SUBREG && GET_CODE (subreg_reg) == PLUS
       && GET_MODE_SIZE (x_mode) <= GET_MODE_SIZE (subreg_reg_mode)
       && CONSTANT_P (XEXP (subreg_reg, 1)))
-    return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg,
-                                                subreg_reg_mode),
-                        XEXP (subreg_reg, 1));
+    {
+      rtx cst = simplify_subreg (x_mode, XEXP (subreg_reg, 1), subreg_reg_mode,
+                                subreg_lowpart_offset (x_mode,
+                                                       subreg_reg_mode));
+      if (cst && CONSTANT_P (cst))
+       return gen_rtx_PLUS (x_mode, lowpart_subreg (x_mode, subreg_reg,
+                                                    subreg_reg_mode), cst);
+    }
   return x;
 }
 
index 9e9423b..aeea559 100644 (file)
@@ -1,5 +1,8 @@
 2016-01-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/69071
+       * gcc.dg/pr69071.c: New test.
+
        PR c++/69211
        * g++.dg/opt/pr69211.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr69071.c b/gcc/testsuite/gcc.dg/pr69071.c
new file mode 100644 (file)
index 0000000..1a17a94
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR target/69071 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+void *bar (void *);
+
+void
+foo (int c)
+{
+  unsigned char bf[65400];
+  unsigned char *p2 = bar (bf);
+  unsigned char *p3 = bar (bf);
+  for (; *p2; p2++, c++)
+    {
+      if (c)
+       {
+         short of = p2 - bf - 6;
+         unsigned ofu = of;
+         __builtin_memcpy (p3, &ofu, sizeof (ofu));
+       }
+    }
+}