re PR tree-optimization/40432 (verify_stmts failed with -O2: non-register as LHS of unary operation)

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
This commit is contained in:
Martin Jambor 2009-06-16 12:16:40 +02:00 committed by Martin Jambor
parent 3bc462c29c
commit 0ec19b8c10
4 changed files with 32 additions and 1 deletions

View 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

View 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.

View File

@ -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;
}

View 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)