This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add DAG combine to fold (fp_to_int_sat (ffloor X)) -> (select X == nan, 0, (fcvt X, rdn))
ClosedPublic

Authored by craig.topper on Jan 8 2022, 11:09 AM.

Details

Summary

Similar for ceil, trunc, round, and roundeven. This allows us to use
static rounding modes to avoid a libcall.

This is similar to D116771, but for the saturating conversions.

This optimization is done for AArch64 as isel patterns.
RISCV doesn't have instructions for ceil/floor/trunc/round/roundeven
so the operations don't stick around until isel to enable a pattern
match. Thus I've implemented a DAG combine.

I'm only handling saturating to i64 or i32. This could be extended
to other sizes in the future.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 8 2022, 11:09 AM
craig.topper requested review of this revision.Jan 8 2022, 11:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2022, 11:09 AM
Herald added a subscriber: MaskRay. · View Herald Transcript
asb accepted this revision.Jan 20 2022, 6:01 AM

Sorry for forgetting about this this one Craig. LGTM.

This revision is now accepted and ready to land.Jan 20 2022, 6:01 AM
This revision was landed with ongoing or failed builds.Jan 20 2022, 11:38 AM
This revision was automatically updated to reflect the committed changes.