aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorTom Eccles <tom.eccles@arm.com>2022-10-19 13:19:28 +0000
committerTom Eccles <tom.eccles@arm.com>2022-12-09 19:55:58 +0000
commite7b6660243d1a4548f7aaac992b777ef0f0ba5b7 (patch)
tree521bb64230a94bd82df4d0e44ef1da2ca268d515 /flang/lib/Frontend/CompilerInvocation.cpp
parent47375160d7ad3dd21e3aa3db594739d24debb8db (diff)
downloadllvm-e7b6660243d1a4548f7aaac992b777ef0f0ba5b7.zip
llvm-e7b6660243d1a4548f7aaac992b777ef0f0ba5b7.tar.gz
llvm-e7b6660243d1a4548f7aaac992b777ef0f0ba5b7.tar.bz2
[flang] Add -ffast-math and -Ofast
clang -cc1 accepts -Ofast. I did not add it to flang -fc1 because this seems redundant because the compiler driver will always resolve -Ofast into -O3 -ffast-math (I added a test for this). -menable-infs is removed from the frontend-forwarding test because if all of the fast-math component flags are present, these will be resolved into the fast-math flag. Instead -menable-infs is tested in the fast-math test. Specifying -ffast-math to the compiler driver causes linker invocations to include crtfastmath.o. RFC: https://discourse.llvm.org/t/rfc-the-meaning-of-ofast/66554 Differential Revision: https://reviews.llvm.org/D138675
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e5fa38e..33ec6af 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -728,6 +728,16 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
opts.ReciprocalMath = true;
}
+ if (args.getLastArg(clang::driver::options::OPT_ffast_math)) {
+ opts.NoHonorInfs = true;
+ opts.NoHonorNaNs = true;
+ opts.AssociativeMath = true;
+ opts.ReciprocalMath = true;
+ opts.ApproxFunc = true;
+ opts.NoSignedZeros = true;
+ opts.setFPContractMode(LangOptions::FPM_Fast);
+ }
+
return true;
}