tree-optimization/118171 - GENERIC folding in PRE results in invalid GIMPLE
PRE applies GENERIC folding to some component ref components which might result in invalid GIMPLE, like a VIEW_CONVERT_EXPR wrapping a REALPART_EXPR as in the PR. The following removes all GENERIC folding in the code re-constructing a GENERIC component-ref from the PRE VN IL. PR tree-optimization/118171 * tree-ssa-pre.cc (create_component_ref_by_pieces_1): Do not fold any component ref parts. * gcc.dg/torture/pr118171.c: New testcase.
This commit is contained in:
parent
2b687ad95d
commit
6488d5b861
2 changed files with 16 additions and 4 deletions
12
gcc/testsuite/gcc.dg/torture/pr118171.c
Normal file
12
gcc/testsuite/gcc.dg/torture/pr118171.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* { dg-do compile } */
|
||||
|
||||
_Complex float f;
|
||||
static int d;
|
||||
|
||||
void
|
||||
foo(char *p)
|
||||
{
|
||||
do {
|
||||
__builtin_memcpy(&d, 3 + p, 2);
|
||||
} while (*(_Complex char *)&f);
|
||||
}
|
|
@ -2622,7 +2622,7 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref,
|
|||
stmts);
|
||||
if (!genop0)
|
||||
return NULL_TREE;
|
||||
return fold_build1 (currop->opcode, currop->type, genop0);
|
||||
return build1 (currop->opcode, currop->type, genop0);
|
||||
}
|
||||
|
||||
case WITH_SIZE_EXPR:
|
||||
|
@ -2634,7 +2634,7 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref,
|
|||
tree genop1 = find_or_generate_expression (block, currop->op0, stmts);
|
||||
if (!genop1)
|
||||
return NULL_TREE;
|
||||
return fold_build2 (currop->opcode, currop->type, genop0, genop1);
|
||||
return build2 (currop->opcode, currop->type, genop0, genop1);
|
||||
}
|
||||
|
||||
case BIT_FIELD_REF:
|
||||
|
@ -2647,7 +2647,7 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref,
|
|||
tree op2 = currop->op1;
|
||||
tree t = build3 (BIT_FIELD_REF, currop->type, genop0, op1, op2);
|
||||
REF_REVERSE_STORAGE_ORDER (t) = currop->reverse;
|
||||
return fold (t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/* For array ref vn_reference_op's, operand 1 of the array ref
|
||||
|
@ -2725,7 +2725,7 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref,
|
|||
if (!genop2)
|
||||
return NULL_TREE;
|
||||
}
|
||||
return fold_build3 (COMPONENT_REF, TREE_TYPE (op1), op0, op1, genop2);
|
||||
return build3 (COMPONENT_REF, TREE_TYPE (op1), op0, op1, genop2);
|
||||
}
|
||||
|
||||
case SSA_NAME:
|
||||
|
|
Loading…
Add table
Reference in a new issue