public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] niter: Fix up unused var warning [PR108457]
@ 2023-01-19 20:08 Jakub Jelinek
  2023-01-20  8:18 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-01-19 20:08 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

tree-ssa-loop-niter.cc (build_cltz_expr) gets unused variable mode
warning on some architectures where C[LT]Z_DEFINED_VALUE_AT_ZERO
macro(s) don't use the first argument (which includes the
defaults.h definitions of:
#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
Other uses of this macro avoid this problem by avoiding temporaries
which are only used as argument to those macros, the following patch
does it the same way for consistency.  Plus some formatting fixes
while at it.

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

2023-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/108457
	* tree-ssa-loop-niter.cc (build_cltz_expr): Use
	SCALAR_INT_TYPE_MODE (utype) directly as C[LT]Z_DEFINED_VALUE_AT_ZERO
	argument instead of a temporary.  Formatting fixes.

--- gcc/tree-ssa-loop-niter.cc.jj	2023-01-16 11:52:05.806885510 +0100
+++ gcc/tree-ssa-loop-niter.cc	2023-01-19 13:10:42.872595970 +0100
@@ -2252,16 +2252,16 @@ build_cltz_expr (tree src, bool leading,
       call = build_call_expr_internal_loc (UNKNOWN_LOCATION, ifn,
 					   integer_type_node, 1, src);
       int val;
-      scalar_int_mode mode = SCALAR_INT_TYPE_MODE (utype);
       int optab_defined_at_zero
-	= leading ? CLZ_DEFINED_VALUE_AT_ZERO (mode, val)
-		  : CTZ_DEFINED_VALUE_AT_ZERO (mode, val);
+	= (leading
+	   ? CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (utype), val)
+	   : CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (utype), val));
       if (define_at_zero && !(optab_defined_at_zero == 2 && val == prec))
 	{
 	  tree is_zero = fold_build2 (NE_EXPR, boolean_type_node, src,
 				      build_zero_cst (TREE_TYPE (src)));
-	  call = fold_build3(COND_EXPR, integer_type_node, is_zero, call,
-			     build_int_cst (integer_type_node, prec));
+	  call = fold_build3 (COND_EXPR, integer_type_node, is_zero, call,
+			      build_int_cst (integer_type_node, prec));
 	}
     }
   else if (prec == 2 * lli_prec)
@@ -2275,22 +2275,22 @@ build_cltz_expr (tree src, bool leading,
       /* We count the zeroes in src1, and add the number in src2 when src1
 	 is 0.  */
       if (!leading)
-	std::swap(src1, src2);
+	std::swap (src1, src2);
       tree call1 = build_call_expr (fn, 1, src1);
       tree call2 = build_call_expr (fn, 1, src2);
       if (define_at_zero)
 	{
 	  tree is_zero2 = fold_build2 (NE_EXPR, boolean_type_node, src2,
 				       build_zero_cst (TREE_TYPE (src2)));
-	  call2 = fold_build3(COND_EXPR, integer_type_node, is_zero2, call2,
-			      build_int_cst (integer_type_node, lli_prec));
+	  call2 = fold_build3 (COND_EXPR, integer_type_node, is_zero2, call2,
+			       build_int_cst (integer_type_node, lli_prec));
 	}
       tree is_zero1 = fold_build2 (NE_EXPR, boolean_type_node, src1,
 				   build_zero_cst (TREE_TYPE (src1)));
-      call = fold_build3(COND_EXPR, integer_type_node, is_zero1, call1,
-			 fold_build2 (PLUS_EXPR, integer_type_node, call2,
-				      build_int_cst (integer_type_node,
-						     lli_prec)));
+      call = fold_build3 (COND_EXPR, integer_type_node, is_zero1, call1,
+			  fold_build2 (PLUS_EXPR, integer_type_node, call2,
+				       build_int_cst (integer_type_node,
+						      lli_prec)));
     }
   else
     {
@@ -2302,14 +2302,13 @@ build_cltz_expr (tree src, bool leading,
 	{
 	  tree is_zero = fold_build2 (NE_EXPR, boolean_type_node, src,
 				      build_zero_cst (TREE_TYPE (src)));
-	  call = fold_build3(COND_EXPR, integer_type_node, is_zero, call,
-			     build_int_cst (integer_type_node, prec));
+	  call = fold_build3 (COND_EXPR, integer_type_node, is_zero, call,
+			      build_int_cst (integer_type_node, prec));
 	}
 
       if (leading && prec < i_prec)
-	call = fold_build2(MINUS_EXPR, integer_type_node, call,
-			   build_int_cst (integer_type_node,
-					  i_prec - prec));
+	call = fold_build2 (MINUS_EXPR, integer_type_node, call,
+			    build_int_cst (integer_type_node, i_prec - prec));
     }
 
   return call;

	Jakub


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

* Re: [PATCH] niter: Fix up unused var warning [PR108457]
  2023-01-19 20:08 [PATCH] niter: Fix up unused var warning [PR108457] Jakub Jelinek
@ 2023-01-20  8:18 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-01-20  8:18 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Thu, 19 Jan 2023, Jakub Jelinek wrote:

> Hi!
> 
> tree-ssa-loop-niter.cc (build_cltz_expr) gets unused variable mode
> warning on some architectures where C[LT]Z_DEFINED_VALUE_AT_ZERO
> macro(s) don't use the first argument (which includes the
> defaults.h definitions of:
> #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
> #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
> Other uses of this macro avoid this problem by avoiding temporaries
> which are only used as argument to those macros, the following patch
> does it the same way for consistency.  Plus some formatting fixes
> while at it.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 2023-01-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/108457
> 	* tree-ssa-loop-niter.cc (build_cltz_expr): Use
> 	SCALAR_INT_TYPE_MODE (utype) directly as C[LT]Z_DEFINED_VALUE_AT_ZERO
> 	argument instead of a temporary.  Formatting fixes.
> 
> --- gcc/tree-ssa-loop-niter.cc.jj	2023-01-16 11:52:05.806885510 +0100
> +++ gcc/tree-ssa-loop-niter.cc	2023-01-19 13:10:42.872595970 +0100
> @@ -2252,16 +2252,16 @@ build_cltz_expr (tree src, bool leading,
>        call = build_call_expr_internal_loc (UNKNOWN_LOCATION, ifn,
>  					   integer_type_node, 1, src);
>        int val;
> -      scalar_int_mode mode = SCALAR_INT_TYPE_MODE (utype);
>        int optab_defined_at_zero
> -	= leading ? CLZ_DEFINED_VALUE_AT_ZERO (mode, val)
> -		  : CTZ_DEFINED_VALUE_AT_ZERO (mode, val);
> +	= (leading
> +	   ? CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (utype), val)
> +	   : CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (utype), val));
>        if (define_at_zero && !(optab_defined_at_zero == 2 && val == prec))
>  	{
>  	  tree is_zero = fold_build2 (NE_EXPR, boolean_type_node, src,
>  				      build_zero_cst (TREE_TYPE (src)));
> -	  call = fold_build3(COND_EXPR, integer_type_node, is_zero, call,
> -			     build_int_cst (integer_type_node, prec));
> +	  call = fold_build3 (COND_EXPR, integer_type_node, is_zero, call,
> +			      build_int_cst (integer_type_node, prec));
>  	}
>      }
>    else if (prec == 2 * lli_prec)
> @@ -2275,22 +2275,22 @@ build_cltz_expr (tree src, bool leading,
>        /* We count the zeroes in src1, and add the number in src2 when src1
>  	 is 0.  */
>        if (!leading)
> -	std::swap(src1, src2);
> +	std::swap (src1, src2);
>        tree call1 = build_call_expr (fn, 1, src1);
>        tree call2 = build_call_expr (fn, 1, src2);
>        if (define_at_zero)
>  	{
>  	  tree is_zero2 = fold_build2 (NE_EXPR, boolean_type_node, src2,
>  				       build_zero_cst (TREE_TYPE (src2)));
> -	  call2 = fold_build3(COND_EXPR, integer_type_node, is_zero2, call2,
> -			      build_int_cst (integer_type_node, lli_prec));
> +	  call2 = fold_build3 (COND_EXPR, integer_type_node, is_zero2, call2,
> +			       build_int_cst (integer_type_node, lli_prec));
>  	}
>        tree is_zero1 = fold_build2 (NE_EXPR, boolean_type_node, src1,
>  				   build_zero_cst (TREE_TYPE (src1)));
> -      call = fold_build3(COND_EXPR, integer_type_node, is_zero1, call1,
> -			 fold_build2 (PLUS_EXPR, integer_type_node, call2,
> -				      build_int_cst (integer_type_node,
> -						     lli_prec)));
> +      call = fold_build3 (COND_EXPR, integer_type_node, is_zero1, call1,
> +			  fold_build2 (PLUS_EXPR, integer_type_node, call2,
> +				       build_int_cst (integer_type_node,
> +						      lli_prec)));
>      }
>    else
>      {
> @@ -2302,14 +2302,13 @@ build_cltz_expr (tree src, bool leading,
>  	{
>  	  tree is_zero = fold_build2 (NE_EXPR, boolean_type_node, src,
>  				      build_zero_cst (TREE_TYPE (src)));
> -	  call = fold_build3(COND_EXPR, integer_type_node, is_zero, call,
> -			     build_int_cst (integer_type_node, prec));
> +	  call = fold_build3 (COND_EXPR, integer_type_node, is_zero, call,
> +			      build_int_cst (integer_type_node, prec));
>  	}
>  
>        if (leading && prec < i_prec)
> -	call = fold_build2(MINUS_EXPR, integer_type_node, call,
> -			   build_int_cst (integer_type_node,
> -					  i_prec - prec));
> +	call = fold_build2 (MINUS_EXPR, integer_type_node, call,
> +			    build_int_cst (integer_type_node, i_prec - prec));
>      }
>  
>    return call;
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

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

end of thread, other threads:[~2023-01-20  8:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 20:08 [PATCH] niter: Fix up unused var warning [PR108457] Jakub Jelinek
2023-01-20  8:18 ` 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).