This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Further bootstrap unbreak (was Re: [PATCH] PR90838: Support ctz idioms)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>, Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 13 Jan 2020 09:55:39 +0100
- Subject: [PATCH] Further bootstrap unbreak (was Re: [PATCH] PR90838: Support ctz idioms)
- References: <VI1PR0801MB212780CDB6061AD5045E74B283770@VI1PR0801MB2127.eurprd08.prod.outlook.com> <CAFiYyc1jRXCMeMXf2nVs7xKD-a91rXKzXbCrqjDmukevehC0Zg@mail.gmail.com> <VI1PR0801MB2127D31D971FFF16190B5E3C83700@VI1PR0801MB2127.eurprd08.prod.outlook.com> <CAFiYyc17VSrJJKvs3wqf949LNm+YTKoed0wojZHCdzy0n_Dx-w@mail.gmail.com> <VI1PR0801MB2127BEA2101FF7697AA1AC66835A0@VI1PR0801MB2127.eurprd08.prod.outlook.com> <CAFiYyc2Nkwje8RFGTHg2EMeUHi5hOC6PeX2YLvcBaKG+yVOAeg@mail.gmail.com> <20200110211551.GB10088@tucnak> <878smedkr0.fsf@igel.home> <20200111163052.GL10088@tucnak>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sat, Jan 11, 2020 at 05:30:52PM +0100, Jakub Jelinek wrote:
> On Sat, Jan 11, 2020 at 05:24:19PM +0100, Andreas Schwab wrote:
> > ../../gcc/tree-ssa-forwprop.c: In function 'bool simplify_count_trailing_zeroes(gimple_stmt_iterator*)':
> > ../../gcc/tree-ssa-forwprop.c:1925:23: error: variable 'mode' set but not used [-Werror=unused-but-set-variable]
> > 1925 | scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
> > | ^~~~
>
> Oops, then I think we need following, but can't commit it until Monday.
Unfortunately, at least when testing x86_64-linux to s390x-linux cross,
there are two warnings instead of just one:
../../gcc/tree-ssa-forwprop.c: In function ‘bool simplify_count_trailing_zeroes(gimple_stmt_iterator*)’:
../../gcc/tree-ssa-forwprop.c:1925:23: warning: variable ‘mode’ set but not used [-Wunused-but-set-variable]
scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
^~~~
../../gcc/tree-ssa-forwprop.c:1932:7: warning: ‘ctzval’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (zero_val != ctzval && !(zero_val == 0 && ctzval == type_size))
^~
at -O0 and just the first one at -O2.
The first warning (or with error with -Werror) can be cured by the
patch I've posted on Saturday, I've successfully bootstrapped/regtested
it in the mean time on x86_64-linux and i686-linux, tested on aarch64-linux
including the testcase and tested on s390x-linux.
Or we could also initialize ctzval as in the following patch to e.g. match
what we do in vr-values.c with *_DEFINED_VALUE_AT_ZERO. Except for the
x86_64-linux/i686-linux bootstrap/regtest, tested similarly to the above.
So, ok for trunk and which one?
2020-01-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/90838
* tree-ssa-forwprop.c (simplify_count_trailing_zeroes): Use
SCALAR_INT_TYPE_MODE directly in CTZ_DEFINED_VALUE_AT_ZERO macro
argument rather than to initialize temporary for targets that
don't use the mode argument at all. Initialize ctzval to avoid
warning at -O0.
--- gcc/tree-ssa-forwprop.c
+++ gcc/tree-ssa-forwprop.c
@@ -1920,10 +1920,10 @@ simplify_count_trailing_zeroes (gimple_stmt_iterator *gsi)
res_ops[1], res_ops[2], zero_val))
{
tree type = TREE_TYPE (res_ops[0]);
- HOST_WIDE_INT ctzval;
+ HOST_WIDE_INT ctzval = 0;
HOST_WIDE_INT type_size = tree_to_shwi (TYPE_SIZE (type));
- scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
- bool zero_ok = CTZ_DEFINED_VALUE_AT_ZERO (mode, ctzval) == 2;
+ bool zero_ok
+ = CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (type), ctzval) == 2;
/* Skip if there is no value defined at zero, or if we can't easily
return the correct value for zero. */
Jakub