]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/89412 (gcc ICE in simplify_subreg, at simplify-rtx.c:6273...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:08:46 +0000 (14:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:08:46 +0000 (14:08 +0200)
Backported from mainline
2019-02-20  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/89412
* expr.c (expand_assignment): If result is a MEM, use change_address
instead of simplify_gen_subreg.

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

From-SVN: r275118

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

index 9a34df2190092b55a871c395b843866dc8c0cf11..e8ef679c84d10e798fae0c8517a9966b896c63d9 100644 (file)
@@ -1,6 +1,12 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-02-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89412
+       * expr.c (expand_assignment): If result is a MEM, use change_address
+       instead of simplify_gen_subreg.
+
        2019-02-20  Jakub Jelinek  <jakub@redhat.com>
                    David Malcolm  <dmalcolm@redhat.com>
 
index 2f27c732ef9724c7efa9c12fedeeb054d2874930..bcba244379c864037cd7dc5c2115506d786ac83d 100644 (file)
@@ -5146,9 +5146,14 @@ expand_assignment (tree to, tree from, bool nontemporal)
                }
              else
                {
-                 rtx from_rtx
-                   = simplify_gen_subreg (GET_MODE (to_rtx), result,
-                                          TYPE_MODE (TREE_TYPE (from)), 0);
+                 rtx from_rtx;
+                 if (MEM_P (result))
+                   from_rtx = change_address (result, GET_MODE (to_rtx),
+                                              NULL_RTX);
+                 else
+                   from_rtx
+                     = simplify_gen_subreg (GET_MODE (to_rtx), result,
+                                            TYPE_MODE (TREE_TYPE (from)), 0);
                  if (from_rtx)
                    {
                      emit_move_insn (XEXP (to_rtx, 0),
index ca814f847063c5a4728dd1d6e6ef0514facb1fbb..ad38331315361e4a2de301957d7d27895c832dd5 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-02-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89412
+       * gcc.c-torture/compile/pr89412.c: New test.
+
        2019-02-20  Jakub Jelinek  <jakub@redhat.com>
                    David Malcolm  <dmalcolm@redhat.com>
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr89412.c b/gcc/testsuite/gcc.c-torture/compile/pr89412.c
new file mode 100644 (file)
index 0000000..0d6ddd5
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR middle-end/89412 */
+
+struct S { double a, b; } d;
+int e;
+double f;
+
+void
+foo ()
+{
+  _Complex double h;
+  while (e)
+    {
+      f = h;
+      *(struct S *) &h = d;
+    }
+}