This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Move ~X | X -> -1 folding
- From: Richard Biener <rguenther at suse dot de>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Marc Glisse <marc dot glisse at inria dot fr>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 30 Jun 2015 15:59:23 +0200 (CEST)
- Subject: Re: [PATCH] Move ~X | X -> -1 folding
- Authentication-results: sourceware.org; auth=none
- References: <20150630084620 dot GN10139 at redhat dot com> <alpine dot DEB dot 2 dot 20 dot 1506301056540 dot 1977 at laptop-mg dot saclay dot inria dot fr> <20150630102407 dot GO10139 at redhat dot com> <alpine dot DEB dot 2 dot 20 dot 1506301337200 dot 1977 at laptop-mg dot saclay dot inria dot fr> <20150630124600 dot GQ10139 at redhat dot com> <alpine dot LSU dot 2 dot 11 dot 1506301447340 dot 22477 at zhemvz dot fhfr dot qr> <20150630125744 dot GS10139 at redhat dot com> <alpine dot LSU dot 2 dot 11 dot 1506301513030 dot 22477 at zhemvz dot fhfr dot qr> <20150630134615 dot GT10139 at redhat dot com>
On Tue, 30 Jun 2015, Marek Polacek wrote:
> On Tue, Jun 30, 2015 at 03:13:14PM +0200, Richard Biener wrote:
> > On Tue, 30 Jun 2015, Marek Polacek wrote:
> >
> > > On Tue, Jun 30, 2015 at 02:47:49PM +0200, Richard Biener wrote:
> > > > On Tue, 30 Jun 2015, Marek Polacek wrote:
> > > >
> > > > > On Tue, Jun 30, 2015 at 01:39:29PM +0200, Marc Glisse wrote:
> > > > > > Does my suggestion to "build the all_ones constant in TREE_TYPE (@0) and
> > > > > > convert that to type" help for that?
> > > > >
> > > > > It appears to work, but it seems weird to me to create a integer constant
> > > > > in one type and then immediately cast it to another type.
> > > >
> > > > Yes. Do you have a testcase now that fails using bools?
> > >
> > > I don't have a testcase that fails with the pattern we currently have, i.e.
> > > the one with tree_nop_conversion_p.
> >
> > I mean with removing tree_nop_conversion_p.
>
> Aha. With tree_nop_conversion_p removed, gcc.dg/binop-notor2.c fails,
> because there we optimize the return statement to "return -1" instead
> of "return 1".
> <https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02179.html>
Hmm ok. That testcase is basically
int foo (_Bool a)
{
return ((int) a) | ((int) ~a);
}
where indeed with unsigned bool (yeah, our bool is unsigned) we
get zero-extension on both arms. Similar issue would show up with
int foo (unsigned char a)
{
return ((int) a) | ((int) ~a);
}
so it's not specific to bools. So yes, the suggestion to
do
(convert { build_all_ones_cst (TREE_TYPE (@0)); })
would work here.
Richard.
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)