This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Tue, 2 Dec 2014 21:44:31 +0100
- Subject: Re: [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
- Authentication-results: sourceware.org; auth=none
- References: <20141202203246 dot GK8214 at virgil dot suse>
> 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 <mjambor@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;