]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/40432 (verify_stmts failed with -O2: non-register as LHS...
authorMartin Jambor <mjambor@suse.cz>
Tue, 16 Jun 2009 10:16:40 +0000 (12:16 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Tue, 16 Jun 2009 10:16:40 +0000 (12:16 +0200)
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.

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

From-SVN: r148522

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

index 36aa10bedeb34678cd30e8c7d09a7df66a6881ae..b0164814370d8a904dc9fab0de7953d4aed195e4 100644 (file)
@@ -1,3 +1,9 @@
+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
index d882c6cb16000c26f59361f727908c881afdda09..02f87d058edeb735c1c3af108d48bf77b9729b89 100644 (file)
@@ -1,3 +1,7 @@
+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.
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 ddb015c2397101699bd9cc9334e45069b48907c8..a2f783afaede53acc6d40dc96c8bda40ddbbd24a 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)