Patchwork Improve tree_unary_nonnegative_warnv_p (PR middle-end/58564)

login
register
mail settings
Submitter Jakub Jelinek
Date Sept. 30, 2013, 1:31 p.m.
Message ID <20130930133124.GV30970@tucnak.zalov.cz>
Download mbox | patch
Permalink /patch/279154/
State New
Headers show

Comments

Jakub Jelinek - Sept. 30, 2013, 1:31 p.m.
Hi!

Related to the last patch, this handles also BOOLEAN_TYPE and
ENUMERAL_TYPE the same as INTEGER_TYPE in tree_unary_nonnegative_warnv_p,
which means we e.g. fold properly the (int) (x != 0 && y != 0) < 0
when (x != 0 && y != 0) has BOOLEAN_TYPE.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-09-30  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/58564
	* fold-const.c (tree_unary_nonnegative_warnv_p): Use
	INTEGRAL_TYPE_P (t) instead of TREE_CODE (t) == INTEGER_TYPE.


	Jakub
Richard Guenther - Sept. 30, 2013, 1:39 p.m.
On Mon, 30 Sep 2013, Jakub Jelinek wrote:

> Hi!
> 
> Related to the last patch, this handles also BOOLEAN_TYPE and
> ENUMERAL_TYPE the same as INTEGER_TYPE in tree_unary_nonnegative_warnv_p,
> which means we e.g. fold properly the (int) (x != 0 && y != 0) < 0
> when (x != 0 && y != 0) has BOOLEAN_TYPE.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-09-30  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/58564
> 	* fold-const.c (tree_unary_nonnegative_warnv_p): Use
> 	INTEGRAL_TYPE_P (t) instead of TREE_CODE (t) == INTEGER_TYPE.
> 
> --- gcc/fold-const.c.jj	2013-09-30 11:19:06.000000000 +0200
> +++ gcc/fold-const.c	2013-09-30 11:47:40.984561868 +0200
> @@ -15448,7 +15448,7 @@ tree_unary_nonnegative_warnv_p (enum tre
>  	    if (TREE_CODE (inner_type) == REAL_TYPE)
>  	      return tree_expr_nonnegative_warnv_p (op0,
>  						    strict_overflow_p);
> -	    if (TREE_CODE (inner_type) == INTEGER_TYPE)
> +	    if (INTEGRAL_TYPE_P (inner_type))
>  	      {
>  		if (TYPE_UNSIGNED (inner_type))
>  		  return true;
> @@ -15456,12 +15456,12 @@ tree_unary_nonnegative_warnv_p (enum tre
>  						      strict_overflow_p);
>  	      }
>  	  }
> -	else if (TREE_CODE (outer_type) == INTEGER_TYPE)
> +	else if (INTEGRAL_TYPE_P (outer_type))
>  	  {
>  	    if (TREE_CODE (inner_type) == REAL_TYPE)
>  	      return tree_expr_nonnegative_warnv_p (op0,
>  						    strict_overflow_p);
> -	    if (TREE_CODE (inner_type) == INTEGER_TYPE)
> +	    if (INTEGRAL_TYPE_P (inner_type))
>  	      return TYPE_PRECISION (inner_type) < TYPE_PRECISION (outer_type)
>  		      && TYPE_UNSIGNED (inner_type);
>  	  }
> 
> 	Jakub
> 
>

Patch

--- gcc/fold-const.c.jj	2013-09-30 11:19:06.000000000 +0200
+++ gcc/fold-const.c	2013-09-30 11:47:40.984561868 +0200
@@ -15448,7 +15448,7 @@  tree_unary_nonnegative_warnv_p (enum tre
 	    if (TREE_CODE (inner_type) == REAL_TYPE)
 	      return tree_expr_nonnegative_warnv_p (op0,
 						    strict_overflow_p);
-	    if (TREE_CODE (inner_type) == INTEGER_TYPE)
+	    if (INTEGRAL_TYPE_P (inner_type))
 	      {
 		if (TYPE_UNSIGNED (inner_type))
 		  return true;
@@ -15456,12 +15456,12 @@  tree_unary_nonnegative_warnv_p (enum tre
 						      strict_overflow_p);
 	      }
 	  }
-	else if (TREE_CODE (outer_type) == INTEGER_TYPE)
+	else if (INTEGRAL_TYPE_P (outer_type))
 	  {
 	    if (TREE_CODE (inner_type) == REAL_TYPE)
 	      return tree_expr_nonnegative_warnv_p (op0,
 						    strict_overflow_p);
-	    if (TREE_CODE (inner_type) == INTEGER_TYPE)
+	    if (INTEGRAL_TYPE_P (inner_type))
 	      return TYPE_PRECISION (inner_type) < TYPE_PRECISION (outer_type)
 		      && TYPE_UNSIGNED (inner_type);
 	  }