[flang] Fix complex libm use logic problems
authorRazvan Lupusoru <rlupusoru@nvidia.com>
Wed, 19 Jul 2023 18:29:46 +0000 (11:29 -0700)
committerRazvan Lupusoru <rlupusoru@nvidia.com>
Wed, 19 Jul 2023 20:30:40 +0000 (13:30 -0700)
commit1e27425ada352b97773730999fb0f63fab99a89e
tree1b41afb9f9fb8b3aa2b140cd2a8a5e4875d35b9a
parent480e3e353c73f2d01a9b9f77fec6812ad60b8d92
[flang] Fix complex libm use logic problems

Fix the various complex libm selection logic issues from D155310:
- disableMlirComplex is set to false. This means that using mlir complex
is enabled. Yet, the current code still selects libm.
- If we enable mlir complex, we should not check if use approx is
enabled. Namely, we should use mlir complex either if we enable mlir
complex OR use approx is enabled.

To fix the issues, we flip the logic of `disableMlirComplex` to enable
instead. We set it to false by default since the intention from D155310
is to use libm by default. Then we use a logical `&&` with use approx
so that we select libm when BOTH mlir complex and use approx are
disabled.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D155737
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
flang/test/Lower/Intrinsics/abs.f90
flang/test/Lower/Intrinsics/exp.f90
flang/test/Lower/Intrinsics/log.f90
flang/test/Lower/power-operator.f90
flang/test/Lower/sqrt.f90