GCC options and floating-point correctness (benchmarks)

Roger Sayle roger@eyesopen.com
Sat Mar 27 10:21:00 GMT 2004


On Fri, 26 Mar 2004, Joe Buck wrote:
> I have not seen the assembly code that they are producing.  Evidently
> they do not simply reduce it to a constant, though they take shortcuts.
> So let's be sure before we accuse them.

int foo(double a, double b, double c)
{
  return (a+b)+c == a+(b+c);
}


; -- Machine type IA32
; mark_description "Intel(R) C++ Compiler for 32-bit applications, Version 7.1   Build 20030307Z";
; mark_description "-Qvc6 -Qlocation,link,C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin -nologo -FA -O2 -Ob2";
;ident "Intel(R) C++ Compiler for 32-bit applications, Version 7.1   Build 20030307Z"

_foo	PROC NEAR
.B1.1:                          ; Preds .B1.0
        push      ebx                                           ;2.1
        mov       ebx, esp                                      ;2.1
        and       esp, -8                                       ;2.1
        fld       QWORD PTR [ebx+8]                             ;1.5
        fadd      QWORD PTR [ebx+16]                            ;3.13
        fadd      QWORD PTR [ebx+24]                            ;3.26
        mov       edx, 1                                        ;3.26
        fcomp     st(0)                                         ;3.26
        fnstsw    ax                                            ;3.26
        xor       ecx, ecx                                      ;3.26
        sahf                                                    ;3.26
        mov       eax, edx                                      ;3.26
        je        .L1           ; Prob 50%                      ;3.26
        mov       eax, ecx                                      ;3.26
.L1:                                                            ;
        mov       esp, ebx                                      ;3.26
        pop       ebx                                           ;3.26
        ret                                                     ;3.26


Roger
--



More information about the Gcc mailing list