https://llvm.org/bugs/show_bug.cgi?id=27372
Bug ID: 27372 Summary: -fno-associative-math is not honored Product: new-bugs Version: unspecified Hardware: PC OS: Windows NT Status: NEW Severity: normal Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: warren_ris...@playstation.sony.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Re-association enabled via '-ffast-math' is not suppressed with '-fno-associative-math'. Consider the following test-case: // -O1 -ffast-math -fno-associative-math float foo(float a, float x) { return ((a + x) - x); } Compiling at -O1, results in an Add and a Subtract, as expected. Enabling fast-math, allows re-association to happen, and the arithmetic ops are folded away, also as expected. But enabling fast-math while explicitly disabling associative-math doesn't suppress the re-association (the arithmetic ops are still folded away). Specifically: $ clang++ --version clang version 3.9.0 (trunk 266451) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/warren/llvm/bin $ clang++ -c -O1 test.cpp $ objdump -d test.o test.o: file format elf64-x86-64 ... 0000000000000000 <_Z3fooff>: 0: f3 0f 58 c1 addss %xmm1,%xmm0 4: f3 0f 5c c1 subss %xmm1,%xmm0 8: c3 retq $ clang++ -c -O1 -ffast-math test.cpp $ objdump -d test.o ... 0000000000000000 <_Z3fooff>: 0: c3 retq $ clang++ -c -O1 -ffast-math -fno-associative-math test.cpp $ objdump -d test.o ... 0000000000000000 <_Z3fooff>: 0: c3 retq $ GCC does honor the '-fno-associative-math' switch (tested with GCC 4.9.2): $ g++ -c -O1 test.cpp $ objdump -d test.o test.o: file format elf64-x86-64 ... 0000000000000000 <_Z3fooff>: 0: f3 0f 58 c1 addss %xmm1,%xmm0 4: f3 0f 5c c1 subss %xmm1,%xmm0 8: c3 retq $ g++ -c -O1 -ffast-math test.cpp $ objdump -d test.o ... 0000000000000000 <_Z3fooff>: 0: f3 c3 repz retq $ g++ -c -O1 -ffast-math -fno-associative-math test.cpp $ objdump -d test.o ... 0000000000000000 <_Z3fooff>: 0: f3 0f 58 c1 addss %xmm1,%xmm0 4: f3 0f 5c c1 subss %xmm1,%xmm0 8: c3 retq $ This appears to be target-independent behavior (noticed on X86, but tried with a few other architectures, and observed the same issue). Also, tested with a handful of Clang versions, and it's a longstanding behavior. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs