This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Add computeKnownBits support for ISD::USUBSAT.
ClosedPublic

Authored by craig.topper on Mar 6 2021, 6:38 PM.

Details

Summary

The result of ISD::USUBSAT will never be larger than the LHS. We
can use this to put a bound on the number of leading zeros.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 6 2021, 6:38 PM
craig.topper requested review of this revision.Mar 6 2021, 6:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2021, 6:38 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
craig.topper added inline comments.Mar 6 2021, 6:42 PM
llvm/test/CodeGen/X86/usub_sat_plus.ll
135

This is still less than optimal. The movzbl at line 133 is really an any_extend. The other operand of the cmovbl is 0. Had we used a zero_extend at 133 this movzbl wouldn't be needed.

RKSimon accepted this revision.Mar 7 2021, 3:03 AM

LGTM

llvm/test/CodeGen/X86/usub_sat_plus.ll
135

Its sort of related to PR40881 - which complains about a similar thing resulting in ZEXTLOAD vs EXTLOAD.

This revision is now accepted and ready to land.Mar 7 2021, 3:03 AM
This revision was landed with ongoing or failed builds.Mar 7 2021, 9:54 AM
This revision was automatically updated to reflect the committed changes.