[flang] Support aint/anint for 80/128 bit in lowering
authorPeixin Qiao <qiaopeixin@huawei.com>
Sat, 23 Jul 2022 06:44:20 +0000 (14:44 +0800)
committerPeixin Qiao <qiaopeixin@huawei.com>
Sat, 23 Jul 2022 06:44:20 +0000 (14:44 +0800)
commit3ccd4ce29ca7f59eb12b077705cde2c11ac13aae
treeac0f4610effeb6d48913113937c29212a06bd82f
parent33c18fbc190d3a1cd38f976b758026247120c412
[flang] Support aint/anint for 80/128 bit in lowering

For aint/anint, LLVM conversion operations llvm.trunc and llvm.round
can support the edge case of aint(-0.) and anint(-0.). The output is -0.
and it is the same of `gfortran` and `classic flang`, while the output
of `ifort` is 0.. The `real(10)/real(16)` is not supported before.
Support it and remove the runtime functions for aint/anint.

For nint, `gfortran`, `ifort`, and LLVM Flang using llvm.lround have
different results when the magnitude of argument is more than the max of
result value range. So delay its support in lowering after more
investigations.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D130024
flang/include/flang/Runtime/numeric.h
flang/lib/Lower/IntrinsicCall.cpp
flang/runtime/numeric.cpp
flang/test/Lower/Intrinsics/aint.f90
flang/test/Lower/Intrinsics/anint.f90
flang/test/Lower/math-lowering.f90
flang/unittests/Runtime/Numeric.cpp