This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG][X86][ARM] Teach ExpandIntRes_ABS to use sra+add+xor expansion when ADDCARRY is supported.
ClosedPublic

Authored by craig.topper on Sep 6 2020, 6:20 PM.

Details

Summary

Rather than using SELECT instructions, use SRA, UADDO/ADDCARRY and
XORs to expand ABS. This is the multi-part version of the sequence
we use in LegalizeDAG.

It's also the same as the Custom sequence uses for i64 on 32-bit
and i128 on 64-bit. So we can remove the X86 customization.

Diff Detail

Event Timeline

craig.topper created this revision.Sep 6 2020, 6:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2020, 6:20 PM
craig.topper requested review of this revision.Sep 6 2020, 6:20 PM
RKSimon added inline comments.Sep 7 2020, 6:05 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
2806

Do we need to test for UADDO legality?

craig.topper added inline comments.Sep 7 2020, 11:08 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
2806

I don't think so. In ExpandIntRes_ADDSUB we check ADDCARRY to choose UADDO/ADDCARRY legalization. If its not legal/custom we check if ADDC is legal/custom for to use ADDC/ADDE. If that doesn't work then we check if UADDO is legal to use UADDO/ADD.

I'm replicating the first part of that where we check ADDCARRY to use UADDO/ADDCARRY.

RKSimon accepted this revision.Sep 7 2020, 11:20 AM

LGTM

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
2806

OK, please add that explanation as a comment here for future reference?

This revision is now accepted and ready to land.Sep 7 2020, 11:20 AM
This revision was landed with ongoing or failed builds.Sep 7 2020, 1:16 PM
This revision was automatically updated to reflect the committed changes.