From 3da3ff4e712aad4d79949ce2875e8748b799c95b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 20 Mar 2015 12:39:32 +0000 Subject: [PATCH] re PR tree-optimization/64715 (__builtin_object_size (..., 1) fails to locate subobject) 2015-03-20 Richard Biener 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 --- gcc/ChangeLog | 11 +++++++++++ gcc/gimplify.c | 17 ----------------- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/c-c++-common/pr19807-1.c | 1 + gcc/testsuite/gcc.dg/pr15347.c | 1 + gcc/tree-chrec.c | 17 +++++++++-------- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3336964..37f5606 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2015-03-20 Richard Biener + + 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 * ipa-inline.c (can_inline_edge_p): Short circuit if inline_failed diff --git a/gcc/gimplify.c b/gcc/gimplify.c index d822913..ff0a225 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7300bb6..884fb62 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-20 Richard Biener + + PR middle-end/64715 + * gcc.dg/pr15347.c: Use -O. + * c-c++-common/pr19807-1.c: Likewise. + 2015-03-20 Eric Botcazou * gnat.dg/volatile13.ad[sb]: New test. diff --git a/gcc/testsuite/c-c++-common/pr19807-1.c b/gcc/testsuite/c-c++-common/pr19807-1.c index 92ee224..9dc685d 100644 --- a/gcc/testsuite/c-c++-common/pr19807-1.c +++ b/gcc/testsuite/c-c++-common/pr19807-1.c @@ -1,4 +1,5 @@ /* { dg-do link } */ +/* { dg-options "-O" } */ extern void link_error(void); int main() diff --git a/gcc/testsuite/gcc.dg/pr15347.c b/gcc/testsuite/gcc.dg/pr15347.c index b95b0ea..a75267f 100644 --- a/gcc/testsuite/gcc.dg/pr15347.c +++ b/gcc/testsuite/gcc.dg/pr15347.c @@ -1,4 +1,5 @@ /* { dg-do link } */ +/* { dg-options "-O" } */ extern void link_error (void); int diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 84ba30e..b599c2c 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -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)) -- 2.7.4