[Bug c/92164] New: Wrong result using builtin rint/rintf optimization in x86_64

steffen-schmidt at siemens dot com gcc-bugzilla@gcc.gnu.org
Mon Oct 21 10:58:00 GMT 2019


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

            Bug ID: 92164
           Summary: Wrong result using builtin rint/rintf optimization in
                    x86_64
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steffen-schmidt at siemens dot com
  Target Milestone: ---

Created attachment 47071
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47071&action=edit
Test source and build script

Dear GCC team,

we've found that the usage of GCCs builtin rint() or rintf() functions on
x86_64 platforms, as are introduced with optimization -O1 and above results in
a change of the runtime result of those functions.

When compiling the attached testprogram with "-O0" or using "-O1
-fno-builtin-rint" the results are as expected as defined by the API. Using
GCCs builtin some of the results differ from the expected values.

It seems operations using FE_DOWNWARD and FE_UPWARD are behaving contrarily for
negative floating point inputs to rint/rintf using builtin rint functions,
resulting in the wrongly rounded value.


The behaviour was reproduced on x86_64 platforms Ubuntu Linux 19.10, MSys2 and
bare metal x86_64 toolchains with GCC compilers 8.2, 9.1, 9.2.1.

Please find attached the bzipped test program (rinttest.tar.bz2), including
build.sh script to compile and run. This should provide a similar output as in
attached text file (rinttest_output.txt).

Please let me know if I can assist any further.

Best, Steffen


More information about the Gcc-bugs mailing list