Re: [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
On Tue, Dec 2, 2014 at 9:32 PM, Martin Jambor mjam...@suse.cz wrote: Hi, apparently it is necessary to check that type sizes match before attempting to fold-V_C_E them in evaluate_conditions_for_known_args. So this patch does this. It passes bootstrap and testing on x86_64-linux and I have verified with a cross compiler that the reported bug is fixed (the generated assembly is the same as before the commit which introduced the problem). OK for trunk and (after a bootstrap and testing there) the 4.9 branch? Thanks, Martin 2014-12-02 Martin Jambor mjam...@suse.cz PR ipa/64153 * ipa-inline-analysis.c (evaluate_conditions_for_known_args): Check type sizes before view_converting. Index: src/gcc/ipa-inline-analysis.c === --- src.orig/gcc/ipa-inline-analysis.c +++ src/gcc/ipa-inline-analysis.c @@ -880,12 +880,19 @@ evaluate_conditions_for_known_args (stru } if (c-code == IS_NOT_CONSTANT || c-code == CHANGED) continue; - val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c-val), val); - res = val - ? fold_binary_to_constant (c-code, boolean_type_node, val, c-val) - : NULL; - if (res integer_zerop (res)) - continue; + + if (operand_equal_p (TYPE_SIZE (TREE_TYPE (c-val)), + TYPE_SIZE (TREE_TYPE (val)), 0)) You can use pointer equality on TYPE_SIZE here. + { + val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c-val), val); + + res = val + ? fold_binary_to_constant (c-code, boolean_type_node, val, c-val) + : NULL; + + if (res integer_zerop (res)) + continue; + } clause |= 1 (i + predicate_first_dynamic_condition); } return clause;
[PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
Hi, apparently it is necessary to check that type sizes match before attempting to fold-V_C_E them in evaluate_conditions_for_known_args. So this patch does this. It passes bootstrap and testing on x86_64-linux and I have verified with a cross compiler that the reported bug is fixed (the generated assembly is the same as before the commit which introduced the problem). OK for trunk and (after a bootstrap and testing there) the 4.9 branch? Thanks, Martin 2014-12-02 Martin Jambor mjam...@suse.cz PR ipa/64153 * ipa-inline-analysis.c (evaluate_conditions_for_known_args): Check type sizes before view_converting. Index: src/gcc/ipa-inline-analysis.c === --- src.orig/gcc/ipa-inline-analysis.c +++ src/gcc/ipa-inline-analysis.c @@ -880,12 +880,19 @@ evaluate_conditions_for_known_args (stru } if (c-code == IS_NOT_CONSTANT || c-code == CHANGED) continue; - val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c-val), val); - res = val - ? fold_binary_to_constant (c-code, boolean_type_node, val, c-val) - : NULL; - if (res integer_zerop (res)) - continue; + + if (operand_equal_p (TYPE_SIZE (TREE_TYPE (c-val)), + TYPE_SIZE (TREE_TYPE (val)), 0)) + { + val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c-val), val); + + res = val + ? fold_binary_to_constant (c-code, boolean_type_node, val, c-val) + : NULL; + + if (res integer_zerop (res)) + continue; + } clause |= 1 (i + predicate_first_dynamic_condition); } return clause;
Re: [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
Hi, apparently it is necessary to check that type sizes match before attempting to fold-V_C_E them in evaluate_conditions_for_known_args. So this patch does this. It passes bootstrap and testing on x86_64-linux and I have verified with a cross compiler that the reported bug is fixed (the generated assembly is the same as before the commit which introduced the problem). OK for trunk and (after a bootstrap and testing there) the 4.9 branch? Thanks, Martin 2014-12-02 Martin Jambor mjam...@suse.cz PR ipa/64153 * ipa-inline-analysis.c (evaluate_conditions_for_known_args): Check type sizes before view_converting. OK, Honza Index: src/gcc/ipa-inline-analysis.c === --- src.orig/gcc/ipa-inline-analysis.c +++ src/gcc/ipa-inline-analysis.c @@ -880,12 +880,19 @@ evaluate_conditions_for_known_args (stru } if (c-code == IS_NOT_CONSTANT || c-code == CHANGED) continue; - val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c-val), val); - res = val - ? fold_binary_to_constant (c-code, boolean_type_node, val, c-val) - : NULL; - if (res integer_zerop (res)) - continue; + + if (operand_equal_p (TYPE_SIZE (TREE_TYPE (c-val)), +TYPE_SIZE (TREE_TYPE (val)), 0)) + { + val = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (c-val), val); + + res = val + ? fold_binary_to_constant (c-code, boolean_type_node, val, c-val) + : NULL; + + if (res integer_zerop (res)) + continue; + } clause |= 1 (i + predicate_first_dynamic_condition); } return clause;