This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Explicit lowering of half <-> double conversions.
ClosedPublic

Authored by simon_tatham on Apr 15 2019, 5:56 AM.

Details

Summary

If an FP_EXTEND or FP_ROUND isel dag node converts directly between
f16 and f32 when the target CPU has no instruction to do it in one go,
it has to be done in two steps instead, going via f32.

Previously, this was done implicitly, because all such CPUs had the
storage-only implementation of f16 (i.e. the only thing you can do
with one at all is to convert it to/from f32). So isel would legalize
the f16 into an f32 as soon as it saw it, by inserting an fp16_to_fp
node (or vice versa), and then the fp_extend would already be f32->f64
rather than f16->f64.

But that technique can't support a target CPU which has full f16
support but _not_ f64, such as some variants of Arm v8.1-M. So now we
provide custom lowering for FP_EXTEND and FP_ROUND, which checks
support for f16 and f64 and decides on the best thing to do given the
combination of flags it gets back.

Event Timeline

simon_tatham created this revision.Apr 15 2019, 5:56 AM

Can this be tested now, or does that depend on one of the other patches?

The code looks reasonable to me, but should be tested.

Remastered patch to apply cleanly against current trunk.

ostannard accepted this revision.Jun 13 2019, 5:51 AM

LGTM except for a few typos in comments.

llvm/lib/Target/ARM/ARMISelLowering.cpp
14432

Typos: convertig, withouth

This revision is now accepted and ready to land.Jun 13 2019, 5:51 AM
This revision was automatically updated to reflect the committed changes.