GPM 1.20.1 problems

Bruce Dubbs bdubbs at swbell.net
Tue Jan 21 20:45:44 PST 2003


Greg Schafer wrote:

>On Tue, Jan 21, 2003 at 09:17:50PM -0600, Bruce Dubbs wrote:
>  
>
>>Interesting.  It sounds like ceil is indeed optimized away.  Can you 
>>post your -Os preproccesed source?
>>    
>>
>
>Umm, sure. But I thought I gave enuff instructions to easily reproduce :)
>
>I've attached a small .bz2 containing
>
>foo.c       the testcase
>foo.i1      preprocessed source at -O1
>foo.is      ""           ""        -Os
>foo.s1      assembly at -O1
>foo.ss      ""          -Os
>  
>

I think I found it. In math.h we have:

#ifdef __USE_EXTERN_INLINES
# include <bits/mathinline.h>
#endif

in bits/mathinline.h we have:

extern __inline double ceil (double __x)
{ register long double __value;
  __volatile unsigned short int __cw;
  __volatile unsigned short int __cwtmp;
  __asm __volatile ("fnstcw %0" : "=m" (__cw));
  __cwtmp = (__cw & 0xf3ff) | 0x0800;
  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
  __asm __volatile ("fldcw %0" : : "m" (__cw));
  return __value;
}

Which substitues inline assembly for the ceil function.  gcc must define 
__USE_EXTERN_INLINES when the -O1 or above optimizations are used.  You 
could force it in -Os by defining before including math.h.  Note that 
calling the functon in glibc *does* decrease the size of the executable 
by about nine instructions but defining the var increases program size.

  -- Bruce

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-dev' in the subject header of the message



More information about the blfs-dev mailing list