summaryrefslogtreecommitdiffstats
path: root/clang/test/Driver/fast-math.c
Commit message (Collapse)AuthorAgeFilesLines
* [Driver, CodeGen] rename options to disable an FP cast optimizationSanjay Patel2018-04-301-8/+8
| | | | | | | | | | | | | | As suggested in the post-commit thread for rL331056, we should match these clang options with the established vocabulary of the corresponding sanitizer option. Also, the use of 'strict' is well-known for these kinds of knobs, and we can improve the descriptive text in the docs. So this intends to match the logic of D46135 but only change the words. Matching LLVM commit to match this spelling of the attribute to follow shortly. Differential Revision: https://reviews.llvm.org/D46236 llvm-svn: 331209
* [Driver, CodeGen] add options to enable/disable an FP cast optimizationSanjay Patel2018-04-271-0/+24
| | | | | | | | | | | | | | | | | | | | | | As discussed in the post-commit thread for: rL330437 ( http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180423/545906.html ) We need a way to opt-out of a float-to-int-to-float cast optimization because too much existing code relies on the platform-specific undefined result of those casts when the float-to-int overflows. The LLVM changes associated with adding this function attribute are here: rL330947 rL330950 rL330951 Also as suggested, I changed the LLVM doc to mention the specific sanitizer flag that catches this problem: rL330958 Differential Revision: https://reviews.llvm.org/D46135 llvm-svn: 331041
* [Driver, CodeGen] pass through and apply -fassociative-mathSanjay Patel2017-12-161-13/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are 2 parts to getting the -fassociative-math command-line flag translated to LLVM FMF: 1. In the driver/frontend, we accept the flag and its 'no' inverse and deal with the interactions with other flags like -ffast-math -fno-signed-zeros -fno-trapping-math. This was mostly already done - we just need to translate the flag as a codegen option. The test file is complicated because there are many potential combinations of flags here. Note that we are matching gcc's behavior that requires 'nsz' and no-trapping-math. 2. In codegen, we map the codegen option to FMF in the IR builder. This is simple code and corresponding test. For the motivating example from PR27372: float foo(float a, float x) { return ((a + x) - x); } $ ./clang -O2 27372.c -S -o - -ffast-math -fno-associative-math -emit-llvm | egrep 'fadd|fsub' %add = fadd nnan ninf nsz arcp contract float %0, %1 %sub = fsub nnan ninf nsz arcp contract float %add, %2 So 'reassoc' is off as expected (and so is the new 'afn' but that's a different patch). This case now works as expected end-to-end although the underlying logic is still wrong: $ ./clang -O2 27372.c -S -o - -ffast-math -fno-associative-math | grep xmm addss %xmm1, %xmm0 subss %xmm1, %xmm0 We're not done because the case where 'reassoc' is set is ignored by optimizer passes. Example: $ ./clang -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math -emit-llvm | grep fadd %add = fadd reassoc float %0, %1 $ ./clang -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math | grep xmm addss %xmm1, %xmm0 subss %xmm1, %xmm0 Differential Revision: https://reviews.llvm.org/D39812 llvm-svn: 320920
* [Driver] Fuchsia defaults to -fno-math-errnoPetr Hosek2017-07-231-0/+2
| | | | | | | | Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D35747 llvm-svn: 308855
* [Driver] Restructure handling of -ffast-math and similar optionsJohn Brawn2017-03-151-4/+17
| | | | | | | | | | | | | | | | | | The way -ffast-math and the various related options to tweak floating-point handling are handled is inflexible and rather confusing. This patch restructures things so that we go through the options adjusting our idea of what's enabled as we go, instead of trying to figure each individual thing out by working backwards from the end, as this makes the behaviour of each individual option more clear. Doing it this way also means we get gcc-compatible behaviour for when the __FAST_MATH__ and __FINITE_MATH_ONLY__ macros are defined, as they should depend on the final set of features that are enabled and not just on -ffast-math and -ffinite-math-only specifically. Differential Revision: http://reviews.llvm.org/D30582 llvm-svn: 297837
* This adds a separate file for the fp denormal regression tests. NFC.Sjoerd Meijer2016-10-031-9/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D24907 llvm-svn: 283109
* Revision r280064 adds new options -fdenormal-fp-math and passes through optionSjoerd Meijer2016-08-311-0/+3
| | | | | | | | | -ffast-math to CC1, but it included a wrong llvm regression tests which was removed in r280065. Although regression test noexceptionsfpmath.c makes sure -fno-trapping-math ends up as a function attribute, this adds a test that explicitly checks the driver output for -fno-trapping-math. llvm-svn: 280227
* Fix for commit 280064 that break the build.Sjoerd Meijer2016-08-301-7/+0
| | | | llvm-svn: 280065
* This adds new options -fdenormal-fp-math and passes through option -ffast-mathSjoerd Meijer2016-08-301-0/+17
| | | | | | | | | | to CC1, which are translated to function attributes and can e.g. be mapped on build attributes FP_exceptions and FP_denormal. Setting these build attributes allows better selection of floating point libraries. Differential Revision: https://reviews.llvm.org/D23840 llvm-svn: 280064
* Process the -freciprocal-math optimization flag (PR20912)Sanjay Patel2015-04-091-0/+15
| | | | | | | | | | | | | | | | | | | | | | | The driver currently accepts but ignores the -freciprocal-math flag. This patch passes the flag through and enables 'arcp' fast-math-flag generation in IR. Note that this change does not actually enable the optimization for any target. The reassociation optimization that this flag specifies was implemented by http://reviews.llvm.org/D6334 : http://llvm.org/viewvc/llvm-project?view=revision&revision=222510 Because the optimization is done in the backend rather than IR, the backend must be modified to understand instruction-level fast-math-flags or a new function-level attribute must be created. Also note that -freciprocal-math is independent of any target-specific usage of reciprocal estimate hardware instructions. That requires its own flag ('-mrecip'). https://llvm.org/bugs/show_bug.cgi?id=20912 llvm-svn: 234493
* Process the -fno-signed-zeros optimization flag (PR20870)Sanjay Patel2015-01-231-0/+15
| | | | | | | | | | | | | | | | | | The driver currently accepts but ignores the -fno-signed-zeros flag. This patch passes the flag through and enables 'nsz' fast-math-flag generation in IR. The existing OpenCL flag for the same functionality is made into an alias here. It may be removed in a subsequent patch. This should resolve bug 20870 ( http://llvm.org/bugs/show_bug.cgi?id=20870 ); patches for the optimizer were checked in at: http://llvm.org/viewvc/llvm-project?view=revision&revision=225050 http://llvm.org/viewvc/llvm-project?view=revision&revision=224583 Differential Revision: http://reviews.llvm.org/D6873 llvm-svn: 226915
* Add a missing pipe in the test from r197896Alp Toker2013-12-231-1/+1
| | | | | | Spotted by Edward llvm-svn: 197903
* Make some f_Group definitions anonymous and test an alternative spellingAlp Toker2013-12-221-0/+3
| | | | | | | | | These names weren't referred to anywhere in the source so don't need a written name. Depends on the TableGen fix for anonymous records in LLVM r197869. llvm-svn: 197896
* Fix a logic bug in the handling of -fmath-errno in the driver. We wouldChandler Carruth2013-05-181-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | imply -fno-math-errno if the user passed -fno-fast-math OR -ffast-math, regardless of in which order and regardless of the tool chain default. I've fixed this to follow the logic: 1) If the last dominating flag is -fno-math-errno, -ffast-math, or -Ofast, then do not use math-errno. 2) If the last dominating flag is an explicit -fmath-errno, do use math-errno. 3) Otherwise, use the toolchain default. This, for example, allows the flag sequence '-ffast-math ... -fno-fast-math' with no mention of '-fmath-errno' or '-fno-math-errno' to preserve the toolchain default. Most notably, this should prevent users trying to disable fast-math optimizations on Darwin and BSD platforms from simultaneously enabling (pointless) -fmath-errno. I've enhanced the tests (after more reorganization) to cover this and other weird permutations of flags and targets. llvm-svn: 182203
* Slight reorganization of the fast-math tests which test for errnoChandler Carruth2013-05-181-10/+6
| | | | | | | setting. Consolidate the collection of tests that enable -fmath-errno and share a single CHECK line for simplicity. llvm-svn: 182202
* clang/test/Driver: Introduce the feature "clang-driver", set if gcc driver ↵NAKAMURA Takumi2012-12-111-1/+1
| | | | | | | | is not used. It is not set at targetting cygming. See PR12920. llvm-svn: 169824
* [driver] Add support for the -fno-fast-math option.Chad Rosier2012-09-251-0/+49
| | | | | | rdar://12299433 llvm-svn: 164638
* Driver: Turn the default value for -fmath-errno into a proper target hook ↵Benjamin Kramer2012-05-021-0/+8
| | | | | | | | | | | and disable it by default on more platforms. For now -fno-math-errno is the default on BSD-derived platforms (Darwin, DragonFlyBSD, FreeBSD, NetBSD, OpenBSD). If the default is not right for your platform, please yell. I only verified the result with the default compilers on Darwin and FreeBSD. llvm-svn: 155990
* test/Driver/fast-math.c: Mark this as XFAIL:cygming. They use gcc driver for as.NAKAMURA Takumi2012-04-271-0/+3
| | | | llvm-svn: 155691
* Fix a long-standing bug where Clang had a different default from GCC onChandler Carruth2012-04-261-3/+10
| | | | | | | | | | | | | | | Linux and other (non-Darwin) platforms and have it use -fmath-errno by default (for better or worse). Darwin has seen the light here and uses -fno-math-errno by default, this patch preserves that. If any maintainers for a non-Linux platform would also like to opt-in to -fno-math-errno by default, I'm happy to add folks, but we're currently getting buts and misleading comparisons with GCC due to this difference in behavior on Linux at least. llvm-svn: 155607
* Fix PR11685 by implementing -ffast-math and its various friends in theChandler Carruth2012-01-021-0/+119
Clang driver. This involves a bunch of silly option parsing code to try to carefully emulate GCC's options. Currently, this takes a conservative approach, and unless all of the unsafe optimizations are enabled, none of them are. The fine grained control doesn't seem particularly useful. If it ever becomes useful, we can add that to LLVM first, and then expose it here. This also fixes a few tiny bugs in the flag management around -fhonor-infinities and -fhonor-nans; the flags now form proper sets both for enabling and disabling, with the last flag winning. I've also implemented a moderately terrifying GCC feature where a language change is also provided by the '-ffast-math' flag by defining the __FAST_MATH__ preprocessor macro. This feature is tracked and serialized in the frontend but it isn't used yet. A subsequent patch will add the preprocessor macro and tests for it. I've manually tested that codegen appears to respect this, but I've not dug in enough to see if there is an easy way to test codegen options w/o relying on the particulars of LLVM's optimizations. llvm-svn: 147434
OpenPOWER on IntegriCloud