This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeTypes][RISCV][WebAssembly] Expand ABS in PromoteIntRes_ABS if it will expand to sra+xor+sub later.
ClosedPublic

Authored by craig.topper on Mar 14 2022, 9:27 PM.

Details

Summary

If we promote the ABS and then Expand in LegalizeDAG, then both the
sra and the xor will have their inputs sign extended. This generates
extra code on RISCV which lacks an i8 or i16 sign extend instructon.
If we expand during type legalization, then only the sra will get its
input sign extended. RISCV is able to combine this with the sra by
doing a shift left followed by an sra.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 14 2022, 9:27 PM
craig.topper requested review of this revision.Mar 14 2022, 9:27 PM
craig.topper retitled this revision from [LegalizeTypes] Expand ABS in PromoteIntRes_ABS if it will expand to sra+xor+sub later. to [LegalizeTypes][RISCV][WebAssembly] Expand ABS in PromoteIntRes_ABS if it will expand to sra+xor+sub later..Mar 14 2022, 9:29 PM
craig.topper added a reviewer: tlively.
RKSimon added inline comments.Mar 15 2022, 4:24 AM
llvm/test/CodeGen/RISCV/iabs.ll
20–21

Update the comment?

70–71

Update the comment?

122–123

Update the comment?

172–173

Update the comment?

Remove stale FIXMEs

RKSimon accepted this revision.Mar 15 2022, 8:19 AM

LGTM

This revision is now accepted and ready to land.Mar 15 2022, 8:19 AM
This revision was landed with ongoing or failed builds.Mar 15 2022, 8:31 AM
This revision was automatically updated to reflect the committed changes.