This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Elimination of zext/sext - type promotion pass
- From: Kugan <kugan dot vivekanandarajah at linaro dot org>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jeff Law <law at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 19 Jun 2015 12:37:44 +1000
- Subject: Re: [RFC] Elimination of zext/sext - type promotion pass
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4aAN3KnSHzNyLckHiNBj1wiwNvih9hCymP8fbWmiNNA9g at mail dot gmail dot com> <CAFiYyc0jnw=F-te2Ba1b77cak3_VofY7SEgYBMpTGgTtVRkJzQ at mail dot gmail dot com> <53FEDF34 dot 4090605 at linaro dot org> <CAFiYyc2-Z6TpJfMbkRF2eki=qoCjJywzR1gJZKX9oZ+bh0enow at mail dot gmail dot com> <5407DF57 dot 2040902 at linaro dot org> <CAFiYyc0D22fh2Votpebb=+oxPenJ9UznQYkeX8MRMLe0aTbPqw at mail dot gmail dot com> <540912E1 dot 30505 at linaro dot org> <CAFiYyc1PjsqVrmWu9UnzUu1K2SwfPFer_akQ+-FYQN2UO4Xt4w at mail dot gmail dot com> <545FF8EE dot 1090900 at linaro dot org> <CAFiYyc1i4uuhnB86v_4aym1VTwYmVhGGkoNYb5beuDJwHKmbeA at mail dot gmail dot com> <554303F0 dot 1000103 at linaro dot org> <CAFiYyc3S+ZYr7PMZMWGGwKfXq1k3GX7M80XammiSFwCfukJxnA at mail dot gmail dot com> <556CE742 dot 4090507 at linaro dot org>
ping?
Thanks,
Kugan
On 02/06/15 09:14, Kugan wrote:
>
>
> On 08/05/15 22:48, Richard Biener wrote:
>> You compute which promotions are unsafe, like sources/sinks of memory
>> (I think you miss call arguments/return values and also asm operands here).
>> But instead of simply marking those SSA names as not to be promoted
>> I'd instead split their life-ranges, thus replace
>>
>> _1 = mem;
>>
>> with
>>
>> _2 = mem;
>> _1 = [zs]ext (_2, ...);
>>
>> and promote _1 anyway. So in the first phase I'd do that (and obviously
>> note that _2 isn't to be promoted in the specific example).
>>
>> For promotions that apply I wouldn't bother allocating new SSA names
>> but just "fix" their types (assign to their TREE_TYPE). This also means
>> they have to become anonymous and if they didn't have a !DECL_IGNORED_P
>> decl before then a debug stmt should be inserted at the point of the
>> promotions. So
>>
>> bar_3 = _1 + _2;
>>
>> when promoted would become
>>
>> _4 = _1 + _2;
>> _3 = sext <_4, ...>;
>> # DEBUG bar = (orig-type) _4; // or _3?
>>
>> so you'd basically always promote defs (you have a lot of stmt/operand
>> walking code I didn't look too closely at - but it looks like too much) and
>> the uses get promoted automagically (because you promote the original
>> SSA name). Promotion of constants has to remain, of course.
>
>
> Thanks Richard. I experimented on this idea to understand it better.
> Please see the attached prototype (I am still working on your other
> comments which is not addressed here). Please have a look and let me
> know if this is along what you would expect. I have few questions though.
>
> 1. In the following example above :
> char _1;
> _1 = mem;
>
> when changing with
>
> char _2;
> int _1;
> _2 = mem;
> _1 = [zs]ext (_2, ...);
>
> for the [zs]ext operation we now use BIT_AND_EXPR and ZEXT_EXPR which
> (as of now) requires that the LHS and RHS are of the same type. Are you
> suggesting that we should have a true ZEXT_EXPR and SEXT_EXPR which can
> do the above in the gimple? I am now using CONVER_EXPR and which is the
> source of many optimization issue.
>
> 2. for inline asm (a reduced test case that might not make much as a
> stand alone test-case, but I ran into similar cases with valid programmes)
>
> ;; Function fn1 (fn1, funcdef_no=0, decl_uid=4220, cgraph_uid=0,
> symbol_order=0)
>
> fn1 (short int p1)
> {
> <bb 2>:
> __asm__("" : "=r" p1_2 : "0" p1_1(D));
> return;
>
> }
>
>
> I am generating something like the following which ICEs. What is the
> expected out?
>
> ;; Function fn1 (fn1, funcdef_no=0, decl_uid=4220, cgraph_uid=0,
> symbol_order=0)
>
> fn1 (short int p1)
> {
> int _1;
> int _2;
> short int _5;
>
> <bb 2>:
> _1 = (int) p1_4(D);
> _5 = (short int) _1;
> __asm__("" : "=r" p1_6 : "0" _5);
> _2 = (int) p1_6;
> return;
>
> }
>
> Thanks a lot for your time,
> Kugan
>