Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 May 2003 02:42:25 -0700
From:      David Schultz <das@FreeBSD.ORG>
To:        Mikhail Teterin <mi+mx@aldan.algebra.com>
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/43299: march=pentium4 miscompiles msun/src/e_pow.c
Message-ID:  <20030514094225.GA7355@HAL9000.homeunix.com>
In-Reply-To: <200305131630.12451.mi%2Bmx@aldan.algebra.com>
References:  <200305131610.h4DGA8vx007871@freefall.freebsd.org> <20030513180417.GA4917@HAL9000.homeunix.com> <200305131630.12451.mi%2Bmx@aldan.algebra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 13, 2003, Mikhail Teterin wrote:
> It seems like the problem is inside the SET_HIGH_WORD(ax, ix) macro
> on line e_pow.c:214, which expands into
> into
> 
> 	do {
> 		ieee_double_shape_type sh_u;
> 
> 		sh_u.value = (ax);
> 		sh_u.parts.msw = (ix);
> 		(ax) = sh_u.value;
> 	} while (0);
> 
> for whatever reason, if compiled for pentium4 with -O1, the line
> 
> 	sh_u.value = (ax)
> 
> is SKIPPED -- according to the debugger. ax ends up filled with junk,
> which screws everything up afterwards... I'm attaching the simple test
> file (the skipped line is 34 in it). If compiled for p3 or for p4 with
> -O0, the result is 0.5. When compiled for p4 with -O1, the result
> is junk. The junk is persistent -- I'm getting ``5.29463e-315'' on
> both FreeBSD (gcc version 3.2.2 20030205) and Linux (gcc version 3.2
> 20020903).

The C standard does not make any provisions for type punning,
except for chars.  However, SET_HIGH_WORD is doing it in the
generally accepted way, which gcc claims to support.  This looks
like a bug in gcc, and you seem to have determined that it is not
FreeBSD specific.  It should probably be reported to the gcc folks
if it is still a problem in a recent gcc 3.3 snapshot.  (It's
great that you found a short test case; they appreciate that.)

BTW, thanks for taking the time to look into this!  I don't have a
P4 to test on or enough free cycles at the moment.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030514094225.GA7355>