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]

Re: Sparc `long long' incorrect code generation



  In message <199710210221.WAA05773@rabi.phys.columbia.edu>you write:
  > 
  > Solaris has a special trap to read the `high resolution timer' which
  > is useful for timing inner loops.  It's exposed as a library call,
  > gethrtime(), the disassembly of which is:
  > 
  > gethrvtime:
  > 	ta 0x24
  > 	retl
  > 	nop
  > 
  > The trap returns a 64 bit value in o0:o1 (hi:lo).  You can write a
  > version of this with gcc's inline asms:
  > 
  > unsigned long long
  > timer(void)
  > {
  >     register unsigned long long val asm("%o0");
  >     asm("ta 0x24" : "=r" (val));
  >     return val;
  > }
  > 
  > gcc 2.7.2 translates this to
  > timer:
  >         save %sp,-112,%sp
  >         ta 0x24
  >         mov %o0,%i0
  >         mov %o1,%i1
  >         ret
  >         restore
  > 
  > which is correct, although it should be optimized to a leaf.  egcs
  > 971016, on the other hand, generates:
  > 
  > timer:
  >         save %sp,-112,%sp
  >         ta 0x24
  >         ret
  >         restore
  > 
  > which, if I understand Sparc register windows correctly, is wrong:
  > the results of the trap will be shifted away and the caller will not
  > see them.
I believe this was fixed a while ago.  I get this with the latest egcs
snapshot:

        !#PROLOGUE# 0
        save %sp,-112,%sp
        !#PROLOGUE# 1
        ta 0x24
        mov %o0,%i0
        mov %o1,%i1
        ret
        restore


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