This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support FP_TO_S/UINT_SAT for i32 and i64.
ClosedPublic

Authored by craig.topper on Jul 31 2021, 12:46 PM.

Details

Summary

The fcvt fp to integer instructions saturate if their input is
infinity or out of range, but the instructions produce a maximum
integer for nan instead of 0 required for the ISD opcodes.

This means we can use the instructions to do the saturating
conversion, but we'll need to fix up the nan case at the end.

We can probably improve the i8 and i16 default codegen as well,
but I'll leave that for a follow up.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 31 2021, 12:46 PM
craig.topper requested review of this revision.Jul 31 2021, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2021, 12:46 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
luismarques accepted this revision.Aug 7 2021, 2:55 PM

LGTM.

BTW, in the tablegen files some pre-existing comments like float->int32 have the width suffix and others don't. I'm not sure if there's any particular logic to that that we should be following?

This revision is now accepted and ready to land.Aug 7 2021, 2:55 PM

LGTM.

BTW, in the tablegen files some pre-existing comments like float->int32 have the width suffix and others don't. I'm not sure if there's any particular logic to that that we should be following?

I'll add the suffixes to the new code entries in this patch.

This revision was landed with ongoing or failed builds.Aug 7 2021, 4:06 PM
This revision was automatically updated to reflect the committed changes.