]> granicus.if.org Git - clang/commit
set the underlying value of “#pragma STDC FP_CONTRACT” on by default
authorSebastian Pop <sebpop@gmail.com>
Fri, 23 Sep 2016 16:16:25 +0000 (16:16 +0000)
committerSebastian Pop <sebpop@gmail.com>
Fri, 23 Sep 2016 16:16:25 +0000 (16:16 +0000)
commit560b6b60eb83c4776255a27e23e95fef73171cf5
treec37c6311baf08a4bec58c6360cd7b51ccbe15c72
parent1349047c2e56a6482b21f1eb7aacc384c4e8f414
set the underlying value of “#pragma STDC FP_CONTRACT” on by default

Clang has the default FP contraction setting of “-ffp-contract=on”, which
doesn't really mean “on” in the conventional sense of the word, but rather
really means “according to the per-statement effective value of the relevant
pragma”.

Before this patch, Clang has that pragma defaulting to “off”. Since the
“-ffp-contract=on” mode is really an AND of two booleans and the second of them
defaults to “off”, the whole thing effectively defaults to “off”. This patch
changes the default value of the pragma to “on”, thus making the default pair of
booleans (on, on) rather than (on, off). This makes FP optimization slightly
more aggressive than before when not using either “-Ofast”, “-ffast-math”, or
“-ffp-contract=fast”. Even with this patch the compiler still respects
“-ffp-contract=off”.

As per a suggestion by Steve Canon, the added code does _not_ require “-O3” or
higher. This is so as to try our best to preserve identical floating-point
results for unchanged source code compiling for an unchanged target when only
changing from any optimization level in the set (“-O0”, “-O1”, “-O2”, “-O3”) to
any other optimization level in that set. “-Os” and “-Oz” seem to be behaving
identically, i.e. should probably be considered a part of the aforementioned
set, but I have not reviewed this rigorously. “-Ofast” is explicitly _not_ a
member of that set.

Patch authored by Abe Skolnik [a.skolnik@samsung.com] and Stephen Canon [scanon@apple.com].

Differential Revision: https://reviews.llvm.org/D24481

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282259 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Frontend/CompilerInvocation.cpp
test/CodeGen/aarch64-neon-fma.c
test/CodeGen/aarch64-scalar-fma.c [new file with mode: 0644]
test/CodeGen/fp-contract-pragma.cpp
test/CodeGen/fp-contract-pragma___on-by-default.c [new file with mode: 0644]
test/Driver/clang_f_opts.c