This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] type promotion pass
- From: Jeff Law <law at redhat dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, "dje dot gcc at gmail dot com" <dje dot gcc at gmail dot com>, "wschmidt at linux dot vnet dot ibm dot com" <wschmidt at linux dot vnet dot ibm dot com>, "kugan dot vivekanandarajah at linaro dot org" <kugan dot vivekanandarajah at linaro dot org>, Richard Biener <richard dot guenther at gmail dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, nd <nd at arm dot com>, "prathamesh dot kulkarni at linaro dot org" <prathamesh dot kulkarni at linaro dot org>
- Date: Fri, 15 Sep 2017 10:56:04 -0600
- Subject: Re: [RFC] type promotion pass
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=law at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF51F7E427
- References: <DB6PR0801MB2053C1BC62931E4B9DEE87CF836C0@DB6PR0801MB2053.eurprd08.prod.outlook.com> <DB6PR0801MB20534EB68F1A0B4B7AE37EE0836C0@DB6PR0801MB2053.eurprd08.prod.outlook.com> <aa070335-2102-0863-a8ed-078f803b3d18@redhat.com> <20170915161909.GG8421@gate.crashing.org>
On 09/15/2017 10:19 AM, Segher Boessenkool wrote:
> On Fri, Sep 15, 2017 at 09:18:23AM -0600, Jeff Law wrote:
>> WORD_REGISTER_OPERATIONS works with PROMOTE_MODE. The reason you can't
>> define WORD_REGISTER_OPERATIONS on aarch64 is because that the implicit
>> promotion is sometimes to 32 bits and sometimes to 64 bits.
>> WORD_REGISTER_OPERATIONS can't really describe that.
>
> WORD_REGISTER_OPERATIONS isn't well-defined.
>
> """
> @defmac WORD_REGISTER_OPERATIONS
> Define this macro to 1 if operations between registers with integral mode
> smaller than a word are always performed on the entire register.
> Most RISC machines have this property and most CISC machines do not.
> @end defmac
> """
>
> Exactly what operations? For almost all targets it isn't true for *all*
> operations. Or no targets even, if you include rotate, etc.
>
> For targets that have both 32-bit and 64-bit operations it is never true
> either.
>
>> And I'm also keen on doing something with type promotion -- Kai did some
>> work in this space years ago which I found interesting, even if the work
>> didn't go forward. It showed a real weakness. So I'm certainly
>> interested in looking at Prathamesh's work -- with the caveat that if it
>> stumbles across the same issues as Kai's work that it likely wouldn't be
>> acceptable in its current form.
>
> Doing type promotion too aggressively reduces code quality. "Just" find
> a sweet spot :-)
>
> Example: on Power, an AND of QImode with 0xc3 is just one insn, which
> actually does a SImode AND with 0xffffffc3. This is what we do currently.
> A SImode AND with 0x000000c3 is two insns, or one if we allow it to write
> to CR0 as well ("andi."); same for DImode, except there isn't a way to do
> an AND with 0xffffffffffffffc3 in one insn at all.
>
> unsigned char a;
> void f(void) { a &= 0xc3; };
Yes, these are some of the things we kicked around. One of the most
interesting conclusions was that for these target issues we'd really
like a target.pd file to handle this class of transformations just prior
to rtl expansion.
Essentially early type promotion/demotion would be concerned with cases
where we can eliminate operations in a target independent manner and
narrow operands as much as possible. Late promotion/demotion would deal
with stuff like the target's desire to work on specific sized hunks in
specific contexts.
I'm greatly oversimplifying here. Type promotion/demotion is fairly
complex to get right.
jeff