This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Custom lower (i32 (fptoui/fptosi X)).
ClosedPublic

Authored by craig.topper on Jul 20 2021, 12:27 AM.

Details

Summary

I stumbled onto a case where our (sext_inreg (assertzexti32 (fptoui X)), i32)
isel pattern can cause an fcvt.wu and fcvt.lu to be emitted if
the assertzexti32 has an additional user. If we add a one use check
it would just cause a fcvt.lu followed by a sext.w when only need
a fcvt.wu to satisfy both users.

To mitigate this I've added custom isel and new ISD opcodes for
fcvt.wu. This allows us to keep know it started life as a conversion
to i32 without needing to match multiple nodes. ComputeNumSignBits
has been taught that this new nodes produces 33 sign bits. To
prevent regressions when we need to zero extend the result of an
(i32 (fptoui X)), I've added a DAG combine to convert it to an
(i64 (fptoui X)) before type legalization. In most cases this would
happen in InstCombine, but a zero_extend can be created for function
returns or arguments.

To keep everything consistent I've added new nodes for fptosi as well.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 20 2021, 12:27 AM
craig.topper requested review of this revision.Jul 20 2021, 12:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2021, 12:27 AM
Herald added a subscriber: MaskRay. · View Herald Transcript
This revision is now accepted and ready to land.Jul 24 2021, 10:00 AM
This revision was landed with ongoing or failed builds.Jul 24 2021, 10:55 AM
This revision was automatically updated to reflect the committed changes.