This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Improve fptosi.sat lowering
ClosedPublic

Authored by dmgreen on Oct 6 2021, 8:37 AM.

Details

Summary

Improve the lowering of scalar fptosi.sat and fptoui.sat for saturating widths smaller than legal types by using the fact that the legal type will saturate under aarch64, and saturating the result further using min/max.

Diff Detail

Event Timeline

dmgreen created this revision.Oct 6 2021, 8:37 AM
dmgreen requested review of this revision.Oct 6 2021, 8:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2021, 8:37 AM
samtebbs added inline comments.Oct 11 2021, 3:11 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3491

I may be misunderstanding the logic here, but the comment says the saturation to a higher bitwidth and consequent saturation of the result is only valid if the legal conversion is smaller than the saturation width, but with this if statement you're bailing out if the dstwidth is less than the saturation width.

dmgreen added inline comments.Oct 12 2021, 7:50 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3491

The comment should be the other way around. We use the natural saturation to the legal width, then saturate it further.

dmgreen updated this revision to Diff 379630.Oct 14 2021, 3:25 AM

smaller -> larger

This revision is now accepted and ready to land.Oct 14 2021, 6:29 AM
This revision was landed with ongoing or failed builds.Oct 15 2021, 3:12 AM
This revision was automatically updated to reflect the committed changes.