re PR tree-optimization/64715 (__builtin_object_size (..., 1) fails to locate subobject)

2015-03-20  Richard Biener  <rguenther@suse.de>

	PR middle-end/64715
	* tree-chrec.c (chrec_fold_poly_cst): Use useless_type_conversion_p
	for type comparison and gcc_checking_assert.
	(chrec_fold_plus_poly_poly): Likewise.
	(chrec_fold_multiply_poly_poly): Likewise.
	(chrec_convert_1): Likewise.
	* gimplify.c (gimplify_expr): Remove premature folding of
	&X + CST to &MEM[&X, CST].

	* gcc.dg/pr15347.c: Use -O.
	* c-c++-common/pr19807-1.c: Likewise.

From-SVN: r221532
This commit is contained in:
Richard Biener 2015-03-20 12:39:32 +00:00 committed by Richard Biener
parent 1e039275b5
commit 3da3ff4e71
6 changed files with 28 additions and 25 deletions

View File

@ -1,3 +1,14 @@
2015-03-20 Richard Biener <rguenther@suse.de>
PR middle-end/64715
* tree-chrec.c (chrec_fold_poly_cst): Use useless_type_conversion_p
for type comparison and gcc_checking_assert.
(chrec_fold_plus_poly_poly): Likewise.
(chrec_fold_multiply_poly_poly): Likewise.
(chrec_convert_1): Likewise.
* gimplify.c (gimplify_expr): Remove premature folding of
&X + CST to &MEM[&X, CST].
2015-03-20 Jan Hubicka <hubicka@ucw.cz>
* ipa-inline.c (can_inline_edge_p): Short circuit if inline_failed

View File

@ -8524,23 +8524,6 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
post_p, is_gimple_val, fb_rvalue);
recalculate_side_effects (*expr_p);
ret = MIN (r0, r1);
/* Convert &X + CST to invariant &MEM[&X, CST]. Do this
after gimplifying operands - this is similar to how
it would be folding all gimplified stmts on creation
to have them canonicalized, which is what we eventually
should do anyway. */
if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST
&& is_gimple_min_invariant (TREE_OPERAND (*expr_p, 0)))
{
*expr_p = build_fold_addr_expr_with_type_loc
(input_location,
fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (*expr_p)),
TREE_OPERAND (*expr_p, 0),
fold_convert (ptr_type_node,
TREE_OPERAND (*expr_p, 1))),
TREE_TYPE (*expr_p));
ret = MIN (ret, GS_OK);
}
break;
}

View File

@ -1,3 +1,9 @@
2015-03-20 Richard Biener <rguenther@suse.de>
PR middle-end/64715
* gcc.dg/pr15347.c: Use -O.
* c-c++-common/pr19807-1.c: Likewise.
2015-03-20 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/volatile13.ad[sb]: New test.

View File

@ -1,4 +1,5 @@
/* { dg-do link } */
/* { dg-options "-O" } */
extern void link_error(void);
int main()

View File

@ -1,4 +1,5 @@
/* { dg-do link } */
/* { dg-options "-O" } */
extern void link_error (void);
int

View File

@ -78,8 +78,8 @@ chrec_fold_poly_cst (enum tree_code code,
gcc_assert (poly);
gcc_assert (cst);
gcc_assert (TREE_CODE (poly) == POLYNOMIAL_CHREC);
gcc_assert (!is_not_constant_evolution (cst));
gcc_assert (type == chrec_type (poly));
gcc_checking_assert (!is_not_constant_evolution (cst));
gcc_checking_assert (useless_type_conversion_p (type, chrec_type (poly)));
switch (code)
{
@ -124,10 +124,11 @@ chrec_fold_plus_poly_poly (enum tree_code code,
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
if (POINTER_TYPE_P (chrec_type (poly0)))
gcc_assert (ptrofftype_p (chrec_type (poly1)));
gcc_checking_assert (ptrofftype_p (chrec_type (poly1))
&& useless_type_conversion_p (type, chrec_type (poly0)));
else
gcc_assert (chrec_type (poly0) == chrec_type (poly1));
gcc_assert (type == chrec_type (poly0));
gcc_checking_assert (useless_type_conversion_p (type, chrec_type (poly0))
&& useless_type_conversion_p (type, chrec_type (poly1)));
/*
{a, +, b}_1 + {c, +, d}_2 -> {{a, +, b}_1 + c, +, d}_2,
@ -208,8 +209,8 @@ chrec_fold_multiply_poly_poly (tree type,
gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
gcc_assert (chrec_type (poly0) == chrec_type (poly1));
gcc_assert (type == chrec_type (poly0));
gcc_checking_assert (useless_type_conversion_p (type, chrec_type (poly0))
&& useless_type_conversion_p (type, chrec_type (poly1)));
/* {a, +, b}_1 * {c, +, d}_2 -> {c*{a, +, b}_1, +, d}_2,
{a, +, b}_2 * {c, +, d}_1 -> {a*{c, +, d}_1, +, b}_2,
@ -1352,7 +1353,7 @@ chrec_convert_1 (tree type, tree chrec, gimple at_stmt,
return chrec;
ct = chrec_type (chrec);
if (ct == type)
if (useless_type_conversion_p (type, ct))
return chrec;
if (!evolution_function_is_affine_p (chrec))