Skip to content

Commit 16bd9e1

Browse files
committed
niter: Fix up unused var warning [PR108457]
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. 2023-01-20 Jakub Jelinek <[email protected]> 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.
1 parent 0846336 commit 16bd9e1

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

gcc/tree-ssa-loop-niter.cc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,16 +2252,16 @@ build_cltz_expr (tree src, bool leading, bool define_at_zero)
22522252
call = build_call_expr_internal_loc (UNKNOWN_LOCATION, ifn,
22532253
integer_type_node, 1, src);
22542254
int val;
2255-
scalar_int_mode mode = SCALAR_INT_TYPE_MODE (utype);
22562255
int optab_defined_at_zero
2257-
= leading ? CLZ_DEFINED_VALUE_AT_ZERO (mode, val)
2258-
: CTZ_DEFINED_VALUE_AT_ZERO (mode, val);
2256+
= (leading
2257+
? CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (utype), val)
2258+
: CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (utype), val));
22592259
if (define_at_zero && !(optab_defined_at_zero == 2 && val == prec))
22602260
{
22612261
tree is_zero = fold_build2 (NE_EXPR, boolean_type_node, src,
22622262
build_zero_cst (TREE_TYPE (src)));
2263-
call = fold_build3(COND_EXPR, integer_type_node, is_zero, call,
2264-
build_int_cst (integer_type_node, prec));
2263+
call = fold_build3 (COND_EXPR, integer_type_node, is_zero, call,
2264+
build_int_cst (integer_type_node, prec));
22652265
}
22662266
}
22672267
else if (prec == 2 * lli_prec)
@@ -2275,22 +2275,22 @@ build_cltz_expr (tree src, bool leading, bool define_at_zero)
22752275
/* We count the zeroes in src1, and add the number in src2 when src1
22762276
is 0. */
22772277
if (!leading)
2278-
std::swap(src1, src2);
2278+
std::swap (src1, src2);
22792279
tree call1 = build_call_expr (fn, 1, src1);
22802280
tree call2 = build_call_expr (fn, 1, src2);
22812281
if (define_at_zero)
22822282
{
22832283
tree is_zero2 = fold_build2 (NE_EXPR, boolean_type_node, src2,
22842284
build_zero_cst (TREE_TYPE (src2)));
2285-
call2 = fold_build3(COND_EXPR, integer_type_node, is_zero2, call2,
2286-
build_int_cst (integer_type_node, lli_prec));
2285+
call2 = fold_build3 (COND_EXPR, integer_type_node, is_zero2, call2,
2286+
build_int_cst (integer_type_node, lli_prec));
22872287
}
22882288
tree is_zero1 = fold_build2 (NE_EXPR, boolean_type_node, src1,
22892289
build_zero_cst (TREE_TYPE (src1)));
2290-
call = fold_build3(COND_EXPR, integer_type_node, is_zero1, call1,
2291-
fold_build2 (PLUS_EXPR, integer_type_node, call2,
2292-
build_int_cst (integer_type_node,
2293-
lli_prec)));
2290+
call = fold_build3 (COND_EXPR, integer_type_node, is_zero1, call1,
2291+
fold_build2 (PLUS_EXPR, integer_type_node, call2,
2292+
build_int_cst (integer_type_node,
2293+
lli_prec)));
22942294
}
22952295
else
22962296
{
@@ -2302,14 +2302,13 @@ build_cltz_expr (tree src, bool leading, bool define_at_zero)
23022302
{
23032303
tree is_zero = fold_build2 (NE_EXPR, boolean_type_node, src,
23042304
build_zero_cst (TREE_TYPE (src)));
2305-
call = fold_build3(COND_EXPR, integer_type_node, is_zero, call,
2306-
build_int_cst (integer_type_node, prec));
2305+
call = fold_build3 (COND_EXPR, integer_type_node, is_zero, call,
2306+
build_int_cst (integer_type_node, prec));
23072307
}
23082308

23092309
if (leading && prec < i_prec)
2310-
call = fold_build2(MINUS_EXPR, integer_type_node, call,
2311-
build_int_cst (integer_type_node,
2312-
i_prec - prec));
2310+
call = fold_build2 (MINUS_EXPR, integer_type_node, call,
2311+
build_int_cst (integer_type_node, i_prec - prec));
23132312
}
23142313

23152314
return call;

0 commit comments

Comments
 (0)