g++ -std=c++11 -fno-PIE -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynch ronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-fo rmat -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual - pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CO NFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I. ./../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I/opt/gnu64/gcc/gmp/i nclude -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I.. /libdecnumber -I../../gcc/gcc/../libbacktrace -I/opt/gnu64/gcc/gmp/include -o t ree-ssa-loop-niter.o -MT tree-ssa-loop-niter.o -MMD -MP -MF ./.deps/tree-ssa-loo p-niter.TPo ../../gcc/gcc/tree-ssa-loop-niter.cc ../../gcc/gcc/tree-ssa-loop-niter.cc: In function 'tree_node* build_cltz_expr(tr ee, bool, bool)': ../../gcc/gcc/tree-ssa-loop-niter.cc:2255:23: warning: variable 'mode' set but n ot used [-Wunused-but-set-variable] 2255 | scalar_int_mode mode = SCALAR_INT_TYPE_MODE (utype); | ^~~~
Basically C[TL]Z_DEFINED_VALUE_AT_ZERO macro does not always use its arguments so they don't get marked as used ... Simple patch: diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index 65b960461ae..22e7c0f6ea5 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -2253,6 +2253,8 @@ build_cltz_expr (tree src, bool leading, bool define_at_zero) integer_type_node, 1, src); int val; scalar_int_mode mode = SCALAR_INT_TYPE_MODE (utype); + /* mode might not be used by the macro C[TL]Z_DEFINED_AT_ZERO. */ + (void)mode; int optab_defined_at_zero = leading ? CLZ_DEFINED_VALUE_AT_ZERO (mode, val) : CTZ_DEFINED_VALUE_AT_ZERO (mode, val);
On 2023-01-18 4:07 p.m., pinskia at gcc dot gnu.org wrote: > Basically C[TL]Z_DEFINED_VALUE_AT_ZERO macro does not always use its arguments > so they don't get marked as used ... Yes. PA uses the default defines for these macros.
Space between cast and mode. Though I think various other uses of these macros solve this by simply using SCALAR_INT_TYPE_MODE (utype) directly as argument to those macros rather than using a temporary variable.
Created attachment 54307 [details] gcc13-pr108457.patch So I'd prefer this instead.
(In reply to Jakub Jelinek from comment #3) > Space between cast and mode. > Though I think various other uses of these macros solve this by simply using > SCALAR_INT_TYPE_MODE (utype) directly as argument to those macros rather than > using a temporary variable. I am ok with that too. This was just a quick patch to try to help to get it unstuck ...
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:16bd9e14f226e07bf0ffb9d68084c9ad69bf7b45 commit r13-5268-g16bd9e14f226e07bf0ffb9d68084c9ad69bf7b45 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Jan 20 10:23:49 2023 +0100 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 <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.
Should be fixed now.