> What other annoying processor bugs are lurking out there?
Is this really just a processor bug, or are we looking at a IEEE-754
conformance issue? Stfs doesn't appear to do rounding, and correct
rounding is required for IEEE-754 compliance.
Take the below program as an example. When run without frsp,
0x3FFFFFFFFFFFFFFF (1.99999....) is truncated to 0x3FFFFFFF
(1.999999...f) as a result of stfs. Whereas if you put a frsp in there,
then it is correctly rounded to nearest (assuming that is the rounding
mode) and you get 0x40000000 (2.0f, exactly), which is correct. While
this may seem like one bit to you, to certain people, this is the
difference between correct operation and garbage. As it is also
required by the standard, so it is highly likely to be viewed by a
compiler writer as the difference between correct operation and
garbage.
The particular example mentioned at the start of this thread surprised
me. I've seen GCC insert a lot of frsp's where I didn't particularly
want them (right after frsqrte is the most common example), but I
haven't actually seen a case where it was completely unjustified --
frsqrte is a double precision instruction after all, even if it is only
accurate to 5 bits. However, right after a fmadds is completely
unjustified in my opinion. It should probably be reported as a compiler
bug.
Ian
#include <stdint.h>
#include <stdio.h>
int main( void )
{
union
{
uint64_t u;
double d;
}a;
union
{
uint32_t u;
float f;
}b;
register double d;
register double *dp = &a.d;
register float *fp = &b.f;
register int zero = 0;