public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
@ 2014-12-02 20:32 Martin Jambor
  2014-12-02 20:44 ` Jan Hubicka
  2014-12-03  9:33 ` Richard Biener
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Jambor @ 2014-12-02 20:32 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jan Hubicka

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.

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
  2014-12-02 20:32 [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args Martin Jambor
@ 2014-12-02 20:44 ` Jan Hubicka
  2014-12-03  9:33 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Hubicka @ 2014-12-02 20:44 UTC (permalink / raw)
  To: GCC Patches, Jan Hubicka

> 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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args
  2014-12-02 20:32 [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args Martin Jambor
  2014-12-02 20:44 ` Jan Hubicka
@ 2014-12-03  9:33 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2014-12-03  9:33 UTC (permalink / raw)
  To: GCC Patches, Jan Hubicka

On Tue, Dec 2, 2014 at 9:32 PM, Martin Jambor <mjambor@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  <mjambor@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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-03  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-02 20:32 [PATCH, PR 64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args Martin Jambor
2014-12-02 20:44 ` Jan Hubicka
2014-12-03  9:33 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).