[cfe-commits] [PATCH] Add -ffp-contract option.
Chandler Carruth
chandlerc at google.com
Thu Jul 5 17:23:19 PDT 2012
Couple of nit picks on the patch itself, no real issue with the plan:
Index: test/CodeGen/fp-contract.c
===================================================================
--- test/CodeGen/fp-contract.c (revision 0)
+++ test/CodeGen/fp-contract.c (revision 0)
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=powerpc-apple-darwin10
-S -o - %s | FileCheck %s
+
+float fma_test1(float a, float b, float c) {
+// CHECK: fmadds
+ float x = a * b;
+ float y = x + c;
+ return y;
+}
I'd prefer to never check actual codegen from within the Clang test suite.
I wonder if there is a way to get the backend libraries to print out their
flags / state? Then we could just check that, and leave the actual
functional test to the LLC-based tests in LLVM. Anyways, not needed for
your patch -- this is a long standing deficit.
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td (revision 159591)
+++ include/clang/Driver/Options.td (working copy)
@@ -410,6 +410,12 @@
def fno_honor_infinites : Flag<"-fno-honor-infinites">,
Alias<fno_honor_infinities>;
def ftrapping_math : Flag<"-ftrapping-math">, Group<f_Group>;
def fno_trapping_math : Flag<"-fno-trapping-math">, Group<f_Group>;
+def ffp_contract : Joined<"-ffp-contract=">, Group<f_Group>,
+ Flags<[CC1Option]>,
+ HelpText<"Form fused FP ops (e.g. FMAs): "
+ "fast (everywhere) | "
+ "on (according to FP_CONTRACT pragma, default)
| "
+ "off (never fuse)">;
The prevailing style in the options TD files is to maximize the columns w/o
much regard for indentation:
def ffp_contract: Joined<'-ffp-contract=">, Group<f_Group>,
Flags<[CC1Option]>, HelpText<"...................."
".....">;
On Mon, Jul 2, 2012 at 2:43 PM, Lang Hames <lhames at gmail.com> wrote:
> Hi All,
>
> The attached patch adds a -ffp-contract=<style> option which (mostly)
> follows the behavior of GCC's option. Styles are 'fast', for aggressive FMA
> formation, 'on' for FP_CONTRACT compliance, and 'off' for no FMA formation
> (in the future this might be relaxed to FMA formation in cases where the
> result is provably unaffected).
>
> Feedback would be welcome. In particular, I have toggled the fp-contract
> style based on the ffast-math option in Clang::ConstructJob(...) in
> lib/Driver/Tools.cpp. Is that the right place to do that kind of option
> fiddling? (It seems to be where the other fast-math related floating point
> options get handled).
>
> Cheers,
> Lang.
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120705/9e069e98/attachment.html>
More information about the cfe-commits
mailing list