[PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default

Abe Skolnik via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 16:35:39 PDT 2016


Abe created this revision.
Abe added reviewers: scanon, lattner, llvm-commits.

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.

https://reviews.llvm.org/D24481

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma___on-by-default___-O0___aarch64-backend.c
  clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h
  clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1___aarch64-backend.c
  clang/test/CodeGen/fp-contract-pragma___on-by-default___-O2___aarch64-backend.c
  clang/test/CodeGen/fp-contract-pragma___on-by-default___-O3___aarch64-backend.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24481.71073.patch
Type: text/x-patch
Size: 4637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160912/25e28bf4/attachment.bin>


More information about the llvm-commits mailing list