[flang] Add -ffast-math and -Ofast
authorTom Eccles <tom.eccles@arm.com>
Wed, 19 Oct 2022 13:19:28 +0000 (13:19 +0000)
committerTom Eccles <tom.eccles@arm.com>
Fri, 9 Dec 2022 19:55:58 +0000 (19:55 +0000)
commite7b6660243d1a4548f7aaac992b777ef0f0ba5b7
tree521bb64230a94bd82df4d0e44ef1da2ca268d515
parent47375160d7ad3dd21e3aa3db594739d24debb8db
[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
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/docs/FlangDriver.md
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/fast_math.f90 [new file with mode: 0644]
flang/test/Driver/frontend-forwarding.f90
flang/test/Lower/fast-math-arithmetic.f90