This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add VIEW_CONVERT_EXPR to operand_equal_p
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 29 Oct 2015 16:23:13 +0100
- Subject: Re: Add VIEW_CONVERT_EXPR to operand_equal_p
- Authentication-results: sourceware.org; auth=none
- References: <20151014162944 dot GE16672 at kam dot mff dot cuni dot cz> <1456448 dot Tt4DpGVrAE at polaris> <20151021215701 dot GA14675 at atrey dot karlin dot mff dot cuni dot cz> <2210014 dot Qgk3pAbeYD at polaris> <20151029033922 dot GA52478 at kam dot mff dot cuni dot cz> <CAFiYyc2+HEuHcz8Mmp0PeoNvPiXVhv9-K2iRPMAG2Q7ZuFLzQg at mail dot gmail dot com> <20151029150215 dot GA34652 at kam dot mff dot cuni dot cz>
On Thu, Oct 29, 2015 at 4:02 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>
>> IMHO it was always wrong/fragile for backends to look at the actual arguments to
>> decide on the calling convention. The backends should _solely_ rely on
>> gimple_call_fntype and its TYPE_ARG_TYPES here.
>>
>> Of course then there are varargs ... (not sure if we hit this here).
>
> Yep, you have varargs and K&R prototypes, so it can't work this way.
Well, then I suppose we need to compute the ABI upfront when we gimplify
from the orginal args (like we preserve fntype). Having a separate fntype
was really meant to make us preserve the ABI throughout the GIMPLE phase...
>>
>> But yes, the VIEW_CONVERT "stripping" is a bit fragile and I don't remember
>> what exactly we gain from it (when not done on registers).
>
> I guess gain is really limited to Ada - there are very few cases we do VCE otherwise.
> (I think we could do more of them). We can make useless_type_conversion NOP/CONVERT
> only. That in fact makes quite a sense because those are types with gimple operations
> on it. Perhaps also VCE on vectors, but not VCE in general.
>
> Honza
>>
>> But I also don't see where we do the stripping mentioned on memory references.
>> The match.pd pattern doesn't apply to memory, only in the GENERIC path
>> which is guarded with exact type equality. So I can't see where we end up
>> stripping the V_C_E.
>>
>> There is one bogus case still in fold-const.c:
>>
>> case VIEW_CONVERT_EXPR:
>> if (TREE_CODE (op0) == MEM_REF)
>> /* ??? Bogus for aligned types. */
>> return fold_build2_loc (loc, MEM_REF, type,
>> TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1));
>>
>> return NULL_TREE;
>>
>> that comment is only in my local tree ... (we lose alignment info that is
>> on the original MEM_REF type which may be a smaller one).
>>
>> Richard.
>>
>> > Honza
>> >>
>> >>
>> >> * gnat.dg/discr44.adb: New test.
>> >>
>> >> --
>> >> Eric Botcazou
>> >
>> >> -- { dg-do run }
>> >> -- { dg-options "-gnatws" }
>> >>
>> >> procedure Discr44 is
>> >>
>> >> function Ident (I : Integer) return Integer is
>> >> begin
>> >> return I;
>> >> end;
>> >>
>> >> type Int is range 1 .. 10;
>> >>
>> >> type Str is array (Int range <>) of Character;
>> >>
>> >> type Parent (D1, D2 : Int; B : Boolean) is record
>> >> S : Str (D1 .. D2);
>> >> end record;
>> >>
>> >> type Derived (D : Int) is new Parent (D1 => D, D2 => D, B => False);
>> >>
>> >> X1 : Derived (D => Int (Ident (7)));
>> >>
>> >> begin
>> >> if X1.D /= 7 then
>> >> raise Program_Error;
>> >> end if;
>> >> end;
>> >