diff mbox

[PR,64153] Check type sizes before V_C_Eing in evaluate_conditions_for_known_args

Message ID 20141202203246.GK8214@virgil.suse
State New
Headers show

Commit Message

Martin Jambor Dec. 2, 2014, 8:32 p.m. UTC
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.

Comments

Jan Hubicka Dec. 2, 2014, 8:44 p.m. UTC | #1
> 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;
Richard Biener Dec. 3, 2014, 9:33 a.m. UTC | #2
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;
diff mbox

Patch

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;