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]

float to uint conv. requires quad precision fp on sparc 64 ?



Hello all,

Seems like highly suboptimal code is produced for some conversions on sparc64
targets. Below is a summary of what I've observed so far. Any help so as to
why this happens (is it expected ?) and what could be done to improve would be
very appreciated.

Many thanks in advance,

Best Regards,

Olivier

--

This has been observed with a cross compiler to sparc64-vxworks hosted on
solaris2.5.1 built from the current CVS sources and a sparcv9-sun-solaris2.8
compiler built from the subreg_byte branch sources. Both have been configured
without specific options beside --target and --prefix.

The following code :

     void foo (void)
     {
       float f = 2.0;
       unsigned int x;

       x = (unsigned int) f;
     }

... compiled for sparc64-vxworks (-m64 -S) yields two "inefficient" calls to
quad precision floating point library functions :
 
 foo:
        !#PROLOGUE# 0
        save    %sp, -240, %sp
        !#PROLOGUE# 1
        sethi   %hi(.LLC0), %o0
        ld      [%o0+%lo(.LLC0)], %f2
        st      %f2, [%fp-20]
        add     %fp, -48, %o0
        ld      [%fp-20], %f3
        call    _Qp_stoq, 0           <====
         nop
        ldx     [%fp-48], %o0
        ldx     [%fp-40], %o1
        stx     %o0, [%fp-64]
        stx     %o1, [%fp-56]
        add     %fp, -64, %o0
        call    _Qp_qtoui, 0          <====

One weired thing is that with -mhard-quad-float, we get a single fstox
instruction instead, which is not quad precision, hence suggesting that the
soft calls above are not really necessary.

AFAICS, the compiler's behavior significantly differ within expand_fix,
where the applicable conversion code is ...

CODE_FOR_fixuns_trunctfsi2 without hard-quad-float

and 

CODE_FOR_fix_truncsfdi2 with hard-quad-float


In insn-flags.h we find :

line  33 : #define HAVE_fix_truncsfdi2
                  (TARGET_V9 && TARGET_FPU)

line 183 : #define HAVE_fixuns_trunctfsi2
                   (TARGET_FPU && TARGET_ARCH64 && ! TARGET_HARD_QUAD)












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