[LLVMbugs] [Bug 18715] New: clang produces bogus numbers with -ffast-math -mfma -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 3 14:16:11 PST 2014


            Bug ID: 18715
           Summary: clang produces bogus numbers with -ffast-math -mfma
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pdknsk at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ clang --version
Ubuntu clang version 3.5-1~exp1 (trunk) (based on LLVM 3.5)
Target: i386-pc-linux-gnu

Unfortunately I don't have a reduced case, but it takes less than a minute to
get and run the code.

$ wget http://llvm.org/img/LLVM-Logo-Derivative-5.png -O file.png
$ git clone https://github.com/pornel/mediancut-posterizer
$ cd mediancut-posterizer

Now add two lines to posterize.c as described below.

Compile and run.

$ CC=clang make
$ ./posterize -d -Q 100 ../file.png file.png -v
MSE=6.392 (Q=79, 255 levels)

$ make clean
$ CC=clang CFLAGSADD=-mfma make
$ ./posterize -d -Q 100 ../file.png file.png -v
MSE=221.115 (Q=0, 255 levels)

The output is totally false (and so is the file).

The Makefile sets quite a few flags, but only those mentioned in the topic are
relevant. You can just set them as CFLAGS directly if you prefer.

Both GCC 4.8 and ICC 14.0 compile the file correctly with or without FMA.

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/20140203/a05e632b/attachment.html>

More information about the llvm-bugs mailing list