[llvm-bugs] [Bug 44873] New: Wrong optimization: instability of x87 floating-point results leads to nonsense

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 11 08:33:45 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=44873

            Bug ID: 44873
           Summary: Wrong optimization: instability of x87 floating-point
                    results leads to nonsense
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ch3root at openwall.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

x87 floating-point results are effectively unstable due to possible excess
precision. Without extra care, this instability can taint everything around and
lead to nonsense.

Instability is not limited to FP numbers, it extends to integers too:

----------------------------------------------------------------------
#include <stdio.h>

__attribute__((noipa,optnone)) // imagine it in a separate TU
static int opaque(int i) { return i; }

int main()
{
    int z = opaque(1) + 0x1p-60 == 1;

    printf("z = %d\n", z);
    if (z) 
        puts("z is one");
}
----------------------------------------------------------------------
$ clang -std=c11 -pedantic -Wall -Wextra -Wno-unknown-attributes -m32
-march=i686 -O3 test.c && ./a.out
z = 0
z is one
----------------------------------------------------------------------
clang x86-64 version: clang version 11.0.0
(https://github.com/llvm/llvm-project 14ecbd7b8ded18af6c95f6a9957da541d1ec0e80)
----------------------------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200211/731c69dc/attachment.html>


More information about the llvm-bugs mailing list