[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: icc bug on test-frexp-nolibm
From: |
Eric Blake |
Subject: |
Re: icc bug on test-frexp-nolibm |
Date: |
Fri, 05 Nov 2010 07:43:27 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Fedora/3.1.6-1.fc14 Mnenhy/0.8.3 Thunderbird/3.1.6 |
On 11/04/2010 11:43 AM, Eric Blake wrote:
> On 11/03/2010 05:10 PM, Eric Blake wrote:
>> I'm running out of time today to get to the bottom of this, so if anyone
>> else wants to help out, great. If not, I'll see if I can resume testing
>> tomorrow and get a minimal test case that exposes the compiler bug, as
>> well as try and isolate ways to work around it.
>>
>> I'm on a Linux x86_64 machine with icc (ICC) 10.0 20070426.
>>
>> I hate it when a heisenbug disappears because of the mere act of adding
>> debugging hooks. :(
>
> I've reduced it to a minimal testcase:
icc also botches this test-case, which was used by our strtod
replacement. In an odd twist of fate, the miscompilation in strtod was
masked by the miscompilation of test-strtod, so the testsuite wasn't
picking up on this until my cleanups to the testsuite yesterday.
$ cat foo.c
#define _GNU_SOURCE 1
#include <math.h>
#include <assert.h>
double foo (double x, int i)
{
return i ? -x : x;
}
double zero;
int main (void)
{
assert (!signbit (foo (zero, 0)));
assert (signbit (foo (zero, 1)));
return 0;
}
$ icc -o foo foo.c
$ ./foo
foo: foo.c:12: main: Assertion `(( sizeof( foo (zero, 1) ) > sizeof(
double )) ? __signbitl( (long double)(foo (zero, 1)) ) : (( sizeof( foo
(zero, 1) ) == sizeof( float )) ? __signbitf( (float)(foo (zero, 1)) ) :
__signbit( (double)(foo (zero, 1)) )))' failed.
Aborted (core dumped)
$ icc -o foo foo.c -g
$ ./foo
with -g:
(gdb) disas foo
Dump of assembler code for function foo:
0x00000000004005f8 <+0>: push %rbp
0x00000000004005f9 <+1>: mov %rsp,%rbp
0x00000000004005fc <+4>: sub $0x30,%rsp
0x0000000000400600 <+8>: movsd %xmm0,-0x20(%rbp)
0x0000000000400605 <+13>: mov %edi,-0x10(%rbp)
0x0000000000400608 <+16>: mov -0x10(%rbp),%eax
0x000000000040060b <+19>: test %eax,%eax
0x000000000040060d <+21>: jne 0x400617 <foo+31>
0x000000000040060f <+23>: fldl -0x20(%rbp)
0x0000000000400612 <+26>: fstpt -0x30(%rbp)
0x0000000000400615 <+29>: jmp 0x40061f <foo+39>
0x0000000000400617 <+31>: fldl -0x20(%rbp)
0x000000000040061a <+34>: fchs
0x000000000040061c <+36>: fstpt -0x30(%rbp)
0x000000000040061f <+39>: fldt -0x30(%rbp)
0x0000000000400622 <+42>: fstpl -0x18(%rbp)
0x0000000000400625 <+45>: movsd -0x18(%rbp),%xmm0
0x000000000040062a <+50>: leaveq
0x000000000040062b <+51>: retq
without -g:
(gdb) disas foo
Dump of assembler code for function foo:
0x0000000000400b3a <+0>: pxor %xmm1,%xmm1
0x0000000000400b3e <+4>: test %edi,%edi
0x0000000000400b40 <+6>: subsd %xmm0,%xmm1
0x0000000000400b44 <+10>: jne 0x400b49 <foo+15>
0x0000000000400b46 <+12>: movaps %xmm0,%xmm1
0x0000000000400b49 <+15>: movaps %xmm1,%xmm0
0x0000000000400b4c <+18>: retq
0x0000000000400b4d <+19>: nop
So any code that wants to conditionally negate floating-point must
special case 0 due to the icc bug. :(
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature