[flang-commits] [PATCH] D134860: [flang] Add platform-specific intrinsic lowering

Diana Picus via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Sep 29 01:15:08 PDT 2022


rovka created this revision.
rovka added reviewers: klausler, jeanPerier, Meinersbur, eli.friedman.
rovka added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
rovka requested review of this revision.

Make it possible for math operations to be lowered in different ways on
different platforms. Use single precision `hypot` as a case study: on
most platforms, `hypot` can be lowered to `hypotf`. However, the MSVC
runtime is lacking a `hypotf` function and instead uses `_hypotf` (*).
This patch adds a platform check based on the FIR triple (which is
either the triple in the FIR module, or the system default triple) and
uses it to decide how to lower `hypot`.

Fixes https://github.com/llvm/llvm-project/issues/57563

(*) More specifically, MSVC's headers define `hypotf` as an inline
function that just calls `_hypotf`. This works fine for clang, since it
will include those headers, but flang only links with the CRT so we
don't get a free ride.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134860

Files:
  flang/lib/Lower/IntrinsicCall.cpp
  flang/test/Lower/Intrinsics/hypot.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134860.463784.patch
Type: text/x-patch
Size: 5620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220929/e43f1ef0/attachment.bin>


More information about the flang-commits mailing list