This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Custom type legalize i32 ISD::ABS on RV64 without Zbb.
ClosedPublic

Authored by craig.topper on Feb 27 2022, 2:34 PM.

Details

Summary

Default type legalization will create sext_inreg+abs, but we may
not be able to remove the sext_inreg.

Instead this patch expands abs during type legalization to
Y = sraiw X, 31; subw(xor X, Y), Y) which doesn't require the input
to be sign extended.

This gives a big improvement for some neg-abs tests where the
abs is used more than the the neg. Previously the abs was expanded
a different way before and after type legalization. Now they are
expanded in a similar way enabling more CSE.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 27 2022, 2:34 PM
craig.topper requested review of this revision.Feb 27 2022, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2022, 2:34 PM
asb accepted this revision.Feb 28 2022, 4:59 AM

LGTM, thanks.

This revision is now accepted and ready to land.Feb 28 2022, 4:59 AM
This revision was landed with ongoing or failed builds.Feb 28 2022, 9:40 AM
This revision was automatically updated to reflect the committed changes.