OSDN Git Service

PR middle-end/51895
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Jan 2012 14:09:29 +0000 (14:09 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Jan 2012 14:09:29 +0000 (14:09 +0000)
* expr.c (expand_expr_real_1): Handle BLKmode MEM_REF of
non-addressable non-BLKmode base correctly.

* g++.dg/opt/pr51895.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183560 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr51895.C [new file with mode: 0644]

index 2a45134..cd0671a 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/51895
+       * expr.c (expand_expr_real_1): Handle BLKmode MEM_REF of
+       non-addressable non-BLKmode base correctly.
+
 2012-01-26  Michael Matz  <matz@suse.de>
 
        PR tree-optimization/48794
index bd2f6b1..8698f18 100644 (file)
@@ -9327,6 +9327,16 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
                bftype = TREE_TYPE (base);
                if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
                  bftype = TREE_TYPE (exp);
+               else
+                 {
+                   temp = assign_stack_temp (DECL_MODE (base),
+                                             GET_MODE_SIZE (DECL_MODE (base)),
+                                             0);
+                   store_expr (base, temp, 0, false);
+                   temp = adjust_address (temp, BLKmode, offset);
+                   set_mem_size (temp, int_size_in_bytes (TREE_TYPE (exp)));
+                   return temp;
+                 }
                return expand_expr (build3 (BIT_FIELD_REF, bftype,
                                            base,
                                            TYPE_SIZE (TREE_TYPE (exp)),
index 3ff49d7..32baf0e 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/51895
+       * g++.dg/opt/pr51895.C: New test.
+
 2012-01-26  Michael Matz  <matz@suse.de>
 
        PR tree-optimization/48794
diff --git a/gcc/testsuite/g++.dg/opt/pr51895.C b/gcc/testsuite/g++.dg/opt/pr51895.C
new file mode 100644 (file)
index 0000000..84ac5e9
--- /dev/null
@@ -0,0 +1,25 @@
+// PR middle-end/51895
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct S
+{
+  long a;
+  char b;
+  S () : a (0), b (0) {}
+  bool baz ();
+};
+
+__attribute__((noinline)) static bool
+bar (S x, S y)
+{
+  y = x;
+  return y.baz ();
+}
+
+bool
+foo (S x)
+{
+  S y;
+  return bar (x, y);
+}