[flang] Lower Fortran math intrinsic operations into MLIR ops or libm calls.
authorSlava Zakharin <szakharin@nvidia.com>
Wed, 22 Jun 2022 21:41:02 +0000 (14:41 -0700)
committerSlava Zakharin <szakharin@nvidia.com>
Tue, 28 Jun 2022 20:32:19 +0000 (13:32 -0700)
commit9f35657983c5f8370f276156f0351f98ae5296bf
treedd8244603fbd03b294040ba52159b9f17f0ce89c
parent870b6d21839707a3e4c40a29b526995f065a220f
[flang] Lower Fortran math intrinsic operations into MLIR ops or libm calls.

Added new -lower-math-early option that defaults to 'true' that matches
the current math lowering scheme. If set to 'false', the intrinsic math
operations will be lowered to MLIR operations, which should potentially
enable more MLIR optimizations, or libm calls, if there is no corresponding
MLIR operation exists or if "precise" mode is requested.
The generated math MLIR operations are then converted to LLVM dialect
during codegen phase.

The -lower-math-early option is not exposed to users currently. I plan to
get rid of the "early" lowering completely, when "late" lowering
is robust enough to support all math intrinsics that are currently
supported via pgmath. So "late" mode will become default and -lower-math-early
option will not be needed. This will effectively eliminate the mandatory
dependency on pgmath in Fortran lowering, but this is WIP.

Differential Revision: https://reviews.llvm.org/D128385
13 files changed:
flang/include/flang/Optimizer/Support/InitFIR.h
flang/lib/Lower/IntrinsicCall.cpp
flang/lib/Optimizer/CodeGen/CMakeLists.txt
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Intrinsics/late-math-codegen.fir [new file with mode: 0644]
flang/test/Lower/Intrinsics/exp.f90
flang/test/Lower/Intrinsics/log.f90
flang/test/Lower/Intrinsics/math-runtime-options.f90
flang/test/Lower/array-expression-slice-1.f90
flang/test/Lower/late-math-lowering.f90 [new file with mode: 0644]
flang/test/Lower/llvm-math.f90
flang/test/Lower/sqrt.f90
flang/test/Lower/trigonometric-intrinsics.f90