This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeIntegerTypes] Further improve ExpandIntRes_SADDSUBO for targets where SADDO/SSUBO aren't supported.
ClosedPublic

Authored by craig.topper on Feb 23 2021, 12:08 PM.

Details

Summary

Rather than converting 3 signbits to bools and comparing them,
we can do bitwise logic on the whole vector and convert the
resulting sign bit to a bool at the end.

This is still a different algorithm than what we do in LegalizeDAG
through expandSADDOSSUBO. That algorithm needs to know that the
RHS of SSUBO is > 0, but that's costly when the type is split.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 23 2021, 12:08 PM
craig.topper requested review of this revision.Feb 23 2021, 12:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 23 2021, 12:09 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
craig.topper added inline comments.Feb 23 2021, 12:12 PM
llvm/test/CodeGen/RISCV/xaluo.ll
1959

Well this isn't at all interesting for testing smulo. I'll put a different constant here.

Update after fixing test to not allow a mul to become an add.

RKSimon accepted this revision.Feb 24 2021, 2:28 AM

LGTM with one minor

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

This "Node->getOpcode() == ISD::SADDO" is done several times in ExpandIntRes_SADDSUBO now (including a switch that can probably be reduced to an assert + compares).

This revision is now accepted and ready to land.Feb 24 2021, 2:28 AM
This revision was landed with ongoing or failed builds.Feb 24 2021, 10:06 AM
This revision was automatically updated to reflect the committed changes.