OSDN Git Service

2009-06-16 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Jun 2009 10:16:40 +0000 (10:16 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Jun 2009 10:16:40 +0000 (10:16 +0000)
PR tree-optimization/40432
* tree-sra.c (sra_modify_assign): When creating VIEW_CONVERT_EXPR,
check whether we need to force gimple register operand.

* testsuite/gcc.c-torture/compile/pr40432.c: New file.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr40432.c [new file with mode: 0644]
gcc/tree-sra.c

index 36aa10b..b016481 100644 (file)
@@ -1,5 +1,11 @@
 2009-06-16  Martin Jambor  <mjambor@suse.cz>
 
+       PR tree-optimization/40432
+       * tree-sra.c (sra_modify_assign): When creating VIEW_CONVERT_EXPR,
+       check whether we need to force gimple register operand.
+
+2009-06-16  Martin Jambor  <mjambor@suse.cz>
+
        PR tree-optimization/40413
        * tree-sra.c (load_assign_lhs_subreplacements): Pass offset to
        build_ref_for_offset.
index d882c6c..02f87d0 100644 (file)
@@ -1,5 +1,9 @@
 2009-06-16  Martin Jambor  <mjambor@suse.cz>
 
+       * testsuite/gcc.c-torture/compile/pr40432.c: New file.
+
+2009-06-16  Martin Jambor  <mjambor@suse.cz>
+
        * testsuite/gfortran.fortran-torture/compile/pr40413.f90: New file.
 
 2009-06-16  Janus Weil  <janus@gcc.gnu.org>
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40432.c b/gcc/testsuite/gcc.c-torture/compile/pr40432.c
new file mode 100644 (file)
index 0000000..767f594
--- /dev/null
@@ -0,0 +1,17 @@
+/* Test that SRA produces valid gimple when handling both type punning by means
+   of VCE and creating an access to a union.  */
+
+union U {
+  struct something *sth;
+  void *nothing;
+};
+
+void
+foo (union U *target, void *p)
+{
+  union U u;
+
+  u.nothing = p;
+  *target = u;
+  return;
+}
index ddb015c..a2f783a 100644 (file)
@@ -2096,7 +2096,11 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
                rhs = expr;
            }
          if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs)))
-           rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs);
+           {
+             rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs);
+             if (!is_gimple_reg (lhs))
+               force_gimple_rhs = true;
+           }
        }
 
       if (force_gimple_rhs)