[flang] Try to lower math intrinsics to math operations first.
authorSlava Zakharin <szakharin@nvidia.com>
Tue, 19 Jul 2022 22:35:56 +0000 (15:35 -0700)
committerSlava Zakharin <szakharin@nvidia.com>
Fri, 22 Jul 2022 16:04:44 +0000 (09:04 -0700)
commitf5759add702eb0b1243198d7f49b7a010b977f5d
tree23c6d8764f2ae9d96e2f878c42e89c61e2c0c3c7
parentfa3c77043800176d5790729de1365013ccb6c393
[flang] Try to lower math intrinsics to math operations first.

This commit changes how math intrinsics are lowered: we, first,
try to lower them into MLIR operations or libm calls via
mathOperations table and only then fallback to pgmath runtime calls.

The pgmath fallback is needed, because mathOperations does not
support all intrinsics that pgmath supports. The main purpose
of this change is to get rid of llvmIntrinsics table so that
we do not have to update both llvmIntrinsics and mathOperations
when adding new intrinsic support.

mathOperations lowering should phase out pgmath lowering, when
more operations are available (e.g. power operations being
added in D129809 and D129811; complex type operations from
Complex dialect).

Differential Revision: https://reviews.llvm.org/D130129
19 files changed:
flang/lib/Lower/IntrinsicCall.cpp
flang/test/Intrinsics/math-codegen.fir [moved from flang/test/Intrinsics/late-math-codegen.fir with 100% similarity]
flang/test/Lower/Intrinsics/abs.f90
flang/test/Lower/Intrinsics/anint.f90
flang/test/Lower/Intrinsics/ceiling.f90
flang/test/Lower/Intrinsics/exp.f90
flang/test/Lower/Intrinsics/floor.f90
flang/test/Lower/Intrinsics/log.f90
flang/test/Lower/Intrinsics/math-runtime-options.f90
flang/test/Lower/Intrinsics/sign.f90
flang/test/Lower/array-elemental-calls-2.f90
flang/test/Lower/array-expression.f90
flang/test/Lower/dummy-procedure.f90
flang/test/Lower/late-math-lowering.f90 [deleted file]
flang/test/Lower/llvm-math.f90 [deleted file]
flang/test/Lower/math-lowering.f90 [new file with mode: 0644]
flang/test/Lower/power-operator.f90
flang/test/Lower/sqrt.f90
flang/test/Lower/trigonometric-intrinsics.f90