This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dse2 remove wrong insn


On Mon, Dec 12, 2011 at 2:48 PM, BELBACHIR Selim
<selim.belbachir@fr.thalesgroup.com> wrote:
> Everything seems good when I use a union instead of "*((int *)(&af))".
>
> But I think that "*((int *)(&af))" is a valid syntax to get the integer representation of my floating point value (in my test case 0x3F800000 for 1.0f in IEEE-754). It may be target dependant but I think it should work on target having 32 bits float and integer (and IEEE754 compliance).

It's valid syntax but invoking undefined behavior.  You can use
-fno-strict-aliasing to make behavior defined (or use a union).

Richard.

> I have gone on my debugging and I found what was wrong in my backend. I had STACK_POINTER_REGNUM=$C0, ARG_POINTER_REGNUM=$C1, FRAME_POINTER_REGNUM=$C0, no reg elimination macro, and prolog/epilog in adequacy. When I replaced my FRAME_POINTER_REGNUM by its own $C2 reg (i.e. a different value than STACK_POINTER_REGNUM) and added reg elimination macros the problem in dse2 pass disappeared (without adding unnecessary frame pointer in the asm output).
> I have done this because looking as dse2.c I saw that some optimization was dealing with frame pointer and I was unsure of the correctness of the macro defining my ABI.
>
> Are there requirement in dse2 pass according to FRAME_POINTER_REGNUM and STACK_POINTER_REGNUM definition ? Does my initial definition of FRAME_POINTER_REGNUM was totally dumb ? I don't know ...
>
> Selim
>
>
> -----Message d'origine-----
> De?: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] De la part de Andrew Haley
> Envoyé?: vendredi 9 décembre 2011 18:37
> À?: gcc@gcc.gnu.org
> Objet?: Re: dse2 remove wrong insn
>
> On 12/09/2011 03:05 PM, BELBACHIR Selim wrote:
>> int main() {
>> ? int x;
>> ? float af;
>> ? ff(&x);
>> ? af = f2(1.0f);
>> ? return *((int *)(&af));
>> }
>
> Please try this again, but with a union rather than a pointer
> cast. ?I don't think this code is legal C.
>
> Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]