Re: GCC and SPARC leaf procedures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't know why, but I rebuilt the toolchain and now it is working (i.e.
it generates leaf procedures). I repeat, it is one of the strangest 
behaviors I have ever noticed. 

Thank you anyway!

Josef

--- On Fri, 10/22/10, Jorge PEREZ <jorge.perez@xxxxxxxx> wrote:

> From: Jorge PEREZ <jorge.perez@xxxxxxxx>
> Subject: Re: GCC and SPARC leaf procedures
> To: "Josef Ahmad" <josef_ahm@xxxxxxxxx>
> Cc: gcc-help@xxxxxxxxxxx
> Date: Friday, October 22, 2010, 11:59 AM
> I checked something else, -O0 gives
> me this
> 
> 40001168 <myleafp>:
> 40001168:Â Â 9d e3 bf 98Â
> ÂÂÂsave %sp, -104, %sp
> 4000116c:Â Â 81 c7 e0 08Â
> ÂÂÂret
> 40001170:Â Â 81 e8 00 00Â
> ÂÂÂrestore
> 
> 40001174 <main>:
> 40001174:Â Â 9d e3 bf 98Â
> ÂÂÂsave %sp, -104, %sp
> 40001178:Â Â 7f ff ff fcÂ
> ÂÂÂcall 40001168 <myleafp>
> 4000117c:Â Â 01 00 00 00Â
> ÂÂÂnop
> 40001180:Â Â 82 10 20 00Â
> ÂÂÂclr %g1  ! 0
> <_trap_table-0x40000000>
> 40001184:Â Â b0 10 00 01Â
> ÂÂÂmov %g1, %i0
> 40001188:Â Â 81 c7 e0 08Â
> ÂÂÂret
> 4000118c:Â Â 81 e8 00 00Â
> ÂÂÂrestore
> 
> but -O2 gives the same as -Os, i.e.
> 
> 40001168 <myleafp>:
> 40001168:Â Â 81 c3 e0 08Â
> ÂÂÂretl
> 4000116c:Â Â 01 00 00 00Â
> ÂÂÂnop
> 
> 40001170 <main>:
> 40001170:Â Â 81 c3 e0 08Â
> ÂÂÂretl
> 40001174:Â Â 90 10 20 00Â
> ÂÂÂclr %o0  ! 0
> <_trap_table-0x40000000>
> 
> so I guess it's not normal that you don't obtain the
> optimization when
> you use -O2
> 
> I confirm, I use sparc-elf 3.4.4
> 
> 
> Cheers,
> 
> 
> George
> 
> 
> 
> Josef Ahmad wrote:
> > No, I looked out for any kind of errors during the
> build of the cross-compiler version 3.4.4, I am quite sure
> the tools are well built. Moreover, the leaf optimization
> procedure is embedded with other back-end routines (I mean,
> they reside into the same source files) and if something
> went wrong during the build, the whole cross-compiler would
> have been broken.
> >
> > Well, I give you an example of the generated code with
> my gcc 3.4.4 cross-compiler (host: i686, target:sparc-elf).
> 
> >
> > - - - C source - - -
> > void myleafp() { return; }
> >
> > int main(){
> >ÂÂÂmyleafp();
> >ÂÂÂreturn 0;
> > }
> > - - -
> >
> > sparc-elf-gcc issued with -O0 and -O2 gives the same
> machine code:
> >
> > - - - obj dump - - -
> > 40001170 <myleafp>:
> > 40001170:Â Â 9d e3 bf 98Â
> ÂÂÂsave %sp, -104, %sp
> > 40001174:Â Â 81 c7 e0 08Â
> ÂÂÂret
> > 40001178:Â Â 81 e8 00 00Â
> ÂÂÂrestore
> >
> > 4000117c <main>:
> > 4000117c:Â Â 9d e3 bf 98Â
> ÂÂÂsave %sp, -104, %sp
> > 40001180:Â Â 7f ff ff fcÂ
> ÂÂÂcall 40001170 <myleafp>
> > 40001184:Â Â 01 00 00 00Â
> ÂÂÂnop
> > 40001188:Â Â 82 10 20 00Â
> ÂÂÂclr %g1  ! 0
> <_trap_table-0x40000000>
> > 4000118c:Â Â b0 10 00 01Â
> ÂÂÂmov %g1, %i0
> > 40001190:Â Â 81 c7 e0 08Â
> ÂÂÂret
> > 40001194:Â Â 81 e8 00 00Â
> ÂÂÂrestore
> > - - - 
> >
> > Does your disassembly show a leaf procedure
> optimization?
> >
> > Josef
> >
> > --- On Fri, 10/22/10, Jorge PEREZ <jorge.perez@xxxxxxxx>
> wrote:
> >
> >ÂÂÂ
> >> From: Jorge PEREZ <jorge.perez@xxxxxxxx>
> >> Subject: Re: GCC and SPARC leaf procedures
> >> To: "Josef Ahmad" <josef_ahm@xxxxxxxxx>,
> gcc-help@xxxxxxxxxxx
> >> Date: Friday, October 22, 2010, 10:44 AM
> >> No problem Josef,
> >>
> >> however, I have tested that with GCC 3.4.4 and I'm
> pretty
> >> sure it does
> >> the optimization there too. Maybe you had an error
> during
> >> the
> >> cross-compiler build?
> >>
> >>
> >> PS: please always reply to the mailing list
> >>
> >>
> >>
> >>
> >> Josef Ahmad wrote:
> >>Â ÂÂÂ
> >>> Eh, you gave me the solution: I was using the
> version
> >>>Â Â ÂÂÂ
> >> 3.4.4 of gcc.
> >>Â ÂÂÂ
> >>> I've just tried to compile my source code with
> gcc
> >>>Â Â ÂÂÂ
> >> 4.4.2 and the optimization works.
> >>Â ÂÂÂ
> >>> It's kind of weird, because there is an
> implementation
> >>>Â Â ÂÂÂ
> >> for the leaf procedures optimization even in the
> former
> >> version, but perhaps it did not work yet.
> >>Â ÂÂÂ
> >>> Now the problem is partially solved, because I
> am
> >>>Â Â ÂÂÂ
> >> using a porting of gcc based on the version 3.4.4,
> and I
> >> would like to know how to obtain a leaf procedure
> >> optimization (if possible) on that version.
> Otherwise, I
> >> think I have to plan to update the porting to a
> newest
> >> version of gcc.
> >>Â ÂÂÂ
> >>> Thank you!
> >>>
> >>> Josef
> >>>
> >>> --- On Fri, 10/22/10, Jorge PEREZ <jorge.perez@xxxxxxxx>
> >>>Â Â ÂÂÂ
> >> wrote:
> >>Â ÂÂÂ
> >>>Â Â 
> >>>Â Â ÂÂÂ
> >>>> From: Jorge PEREZ <jorge.perez@xxxxxxxx>
> >>>> Subject: GCC and SPARC leaf procedures
> >>>> To: gcc-help@xxxxxxxxxxx
> >>>> Cc: josef_ahm@xxxxxxxxx
> >>>> Date: Friday, October 22, 2010, 10:03 AM
> >>>> Hello Josef
> >>>>
> >>>> I was intrigued by your email since I
> actually
> >>>>Â Â Â ÂÂÂ
> >> think that
> >>Â ÂÂÂ
> >>>> GCC performs
> >>>> the leaf procedure optimization as
> indicated by
> >>>>Â Â Â ÂÂÂ
> >> the SPARC
> >>Â ÂÂÂ
> >>>> V8 manual (
> >>>> www.*sparc*.org/standards/*V8*.pdf p.
> 194)
> >>>>
> >>>> However, note that there are certain
> conditions
> >>>>Â Â Â ÂÂÂ
> >> that must
> >>Â ÂÂÂ
> >>>> be met in
> >>>> order to allow such optimizations, quoting
> the
> >>>>Â Â Â ÂÂÂ
> >> above
> >>Â ÂÂÂ
> >>>> referenced manual:
> >>>>
> >>>> Some leaf procedures can be made to
> operate
> >>>>Â Â Â ÂÂÂ
> >> without their
> >>Â ÂÂÂ
> >>>> own register
> >>>> window
> >>>> or stack frame, using their callerâs
> instead.
> >>>>Â Â Â ÂÂÂ
> >> This can be
> >>Â ÂÂÂ
> >>>> done when the
> >>>> candidate
> >>>> leaf procedure meets all of the following
> >>>>Â Â Â ÂÂÂ
> >> conditions13:
> >>Â ÂÂÂ
> >>>> Contains no references to %sp, except in
> its SAVE
> >>>> instruction
> >>>> Contains no references to %fp
> >>>> Refers to (or can be made to refer to) no
> more
> >>>>Â Â Â ÂÂÂ
> >> than 8 of
> >>Â ÂÂÂ
> >>>> the 32 integer
> >>>> regis-
> >>>> ters14, inclusive of %o7 (the âreturn
> >>>>Â Â Â ÂÂÂ
> >> addressâ).
> >>Â ÂÂÂ
> >>>> Actually there is a good example in a
> recent
> >>>>Â Â Â ÂÂÂ
> >> thread
> >>Â ÂÂÂ
> >>>> http://gcc.gnu.org/ml/gcc-help/2010-10/msg00249.html
> >>>> where you can see that in the function
> "somme",
> >>>>Â Â Â ÂÂÂ
> >> which I
> >>Â ÂÂÂ
> >>>> think is a leaf
> >>>> procedure, the SAVE and RESTORE
> instructions have
> >>>>Â Â Â ÂÂÂ
> >> been
> >>Â ÂÂÂ
> >>>> removed. What do
> >>>> you think?
> >>>>
> >>>>
> >>>> Otherwise, which GCC version are you
> using? I
> >>>>Â Â Â ÂÂÂ
> >> don't think
> >>Â ÂÂÂ
> >>>> that can be
> >>>> related to that, but just to be sure.
> >>>>
> >>>> Cheers,
> >>>>
> >>>>
> >>>> George
> >>>>
> >>>>
> >>>>Â Â Â 
> >>>>Â Â Â ÂÂÂ
> >>>Â Â Â Â 
> >>>
> >>>Â Â 
> >>>Â Â ÂÂÂ
> >>
> >>Â ÂÂÂ
> >
> >
> >
> >
> >ÂÂÂ
> 
> 
> 






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux