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

            Bug ID: 82318
           Summary: -fexcess-precision=standard has no effect on a libm
                    function call
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

Consider the following C program:

#include <math.h>

int main (void)
{
  double r = 5.0;
  return (double) log2 (r) == (double) log2 (r) ? 0 : 1;
}

When compiled on x86_64 with -O0 -m32 -fexcess-precision=standard, the program
returns 1 instead of 0.

The generated asm code contains:

[...]
        fldl    .LC0
        fstpl   -16(%ebp)
        subl    $8, %esp
        pushl   -12(%ebp)
        pushl   -16(%ebp)
        call    log2
        addl    $16, %esp
        fstpl   -32(%ebp)
        subl    $8, %esp
        pushl   -12(%ebp)
        pushl   -16(%ebp)
        call    log2
        addl    $16, %esp
        fldl    -32(%ebp)
        fucomi  %st(1), %st
[...]

If I understand correctly, the result of the first log2 is stored into memory,
but not the second one.

Reply via email to