Does gcc-2.95.2 procude IEEE-compliant code on DEC-Alpha-OSF4?

Maarten D. de Jong maarten@dutw1294.wbmt.tudelft.nl
Tue Nov 9 06:37:00 GMT 1999


Hi!

I'm not really sure whether this is a bug or not, but since I am not really
familiar with the assembly produced by Unix-compilers I thought I had
better seek some advice.

In the course of a bug hunt on some code, I noticed that programs compiled
using gcc-2.95.2 and cc (V5.6-071, rev. 878) on a Digital Alpha workstation
running Digital Unix 4.0d do not always emit identical assembly 
for certain maths operations. This is especially the case when the cc-
compiler is passed the '-ieee'-option, which makes the generated program
fully IEEE-compliant in nearly all aspects. As far as I could make out,
gcc produces mnemonics which always end in either a 's' or a 't' (muls,
mult, adds, addt), while the cc-compiler with ieee-option adds an extra
'su' on quite a number of occasions (mulssu, addssu, etc.)

Now all this may not mean very much, but I have compiled a small
diagnostic routine from the Numerical Recipes library, which attempts
to establish the machines' IEEE-parameters. I have done this using both
compilers. The output is nearly identical, except in the case of
rounding---there cc/ieee is fully IEEE-compliant, but gcc is 'halfway'
IEEE-compliant. (It's rather difficult to describe this in words, and
the author's cryptic description of the flag indicating this particular
difference doesn't help at all.)

Here's a sample program to illustrate the difference:

#include <stdio.h>
#include <machine/fpu.h>
#include <float.h>
#include <math.h>

int main()
{
   double x[32];
   int i;

   printf("%lx\n", _get_fpcr());
   for (i=1; i<32; i++)
	x[i]=x[i-1]*sqrt(2.0)+3.9;
   printf("%lx\n", _get_fpcr());

   return 0;
}

-------------------------------
cc -ieee -S fpu.c  : 

....
    multsu  $f4, $f0, $f1
    addtsu  $f1, $f2, $f10
....

-------------------------------
gcc -S fpu.c :

....
    mult $f10,$f11,$f10
    lda $1,$LC2				// ignore 
    ldt $f11,0($1)			// ignore
    addt $f10,$f11,$f10
....

-------------------------------

On top of it all, the gcc-program crashes with a floating point
exception, the cc-program does not. This also indicates differences
in how the FPU is set up, in my opinion.

I was wondering how the difference will/can affect programs which
rely on longer calculations, and whether it is possible to make
gcc emit mnemonics with the 'su'-end as well. (And if yes, how.)


Kind regards,
Maarten D. de Jong


More information about the Gcc-bugs mailing list