https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99621

--- Comment #5 from William Bader <williambader at hotmail dot com> ---
`gcc -S -m32 -O2 bfinal-format.c` with Fedora 32 gcc 10.2.1 gives a section
similar to one in my first comment. In particular, it calls fucomi "floating
unordered compare of st(0) and st(i)" and then fstp "floating store of st(0)
and then pop fpu 
 stack". fstp can change the condition registers set by fucomi. It sets C1 for
stack underflow, and its actions on C0, C2, and C3 are undefined. Does every
place that generates fstp in config/i386/i386.c know that it can modify the C
flags? Maybe the bad executable still works correctly in valgrind because
valgrind's emulation of fstp doesn't trash the C flags.
.L42:
        testl   %esi, %esi
        je      .L43
        fldl    8(%esp)
        faddl   (%esp)
        fstpl   8(%esp)
.L43:
        fldz
        fldl    16(%esp)
        fucomi  %st(1), %st 
        fstp    %st(1)
        jp      .L105
        jne     .L106

Reply via email to