re PR tree-optimization/42998 (ICE: error: verify_stmts failed)

2010-02-11  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42998
	* tree-ssa-pre.c (create_expression_by_pieces): Treat
	POINTER_PLUS_EXPR properly.

	* gcc.c-torture/compile/pr42998.c: New testcase.

From-SVN: r156704
This commit is contained in:
Richard Guenther 2010-02-11 17:01:21 +00:00 committed by Richard Biener
parent 04eadb1326
commit 6d8921479a
4 changed files with 34 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2010-02-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42998
* tree-ssa-pre.c (create_expression_by_pieces): Treat
POINTER_PLUS_EXPR properly.
2010-02-11 Sebastian Pop <sebastian.pop@amd.com>
Changpeng Fang <changpeng.fang@amd.com>

View File

@ -1,3 +1,8 @@
2010-02-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42998
* gcc.c-torture/compile/pr42998.c: New testcase.
2010-02-10 Jason Merrill <jason@redhat.com>
PR c++/41896

View File

@ -0,0 +1,15 @@
void foo(void *);
void bar(void *);
void ndisc_fill_addr_option(unsigned char *opt, int data_len,
unsigned short addr_type)
{
int pad;
if (addr_type == 32)
pad = 2;
else
pad = 0;
__builtin_memset(opt + 2, 0, pad);
opt += pad;
__builtin_constant_p(data_len) ? foo (opt+2) : bar (opt+2);
}

View File

@ -3013,14 +3013,18 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
stmts, domstmt);
if (!genop1 || !genop2)
return NULL_TREE;
genop1 = fold_convert (TREE_TYPE (nary->op[0]),
genop1);
/* Ensure op2 is a sizetype for POINTER_PLUS_EXPR. It
may be a constant with the wrong type. */
if (nary->opcode == POINTER_PLUS_EXPR)
genop2 = fold_convert (sizetype, genop2);
{
genop1 = fold_convert (nary->type, genop1);
genop2 = fold_convert (sizetype, genop2);
}
else
genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
{
genop1 = fold_convert (TREE_TYPE (nary->op[0]), genop1);
genop2 = fold_convert (TREE_TYPE (nary->op[1]), genop2);
}
folded = fold_build2 (nary->opcode, nary->type,
genop1, genop2);