This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][X86] Guard `(X & Y) ==/!= Y` --> `(X & Y) !=/== 0` behind TLI preference
ClosedPublic

Authored by goldstein.w.n on Aug 3 2023, 10:18 AM.

Details

Summary

On X86 for vec types (X & Y) == Y is generally preferable to
(X & Y) != 0. Creating zero requires an extra instruction and on
pre-avx512 targets there is no vector pcmpne so it requires two
additional instructions to invert the pcmpeq.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Aug 3 2023, 10:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 10:18 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Aug 3 2023, 10:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 10:18 AM
RKSimon accepted this revision.Aug 4 2023, 6:04 AM

LGTM with one minor

llvm/include/llvm/CodeGen/TargetLowering.h
687

Please can you move the isXAndYEqZeroPreferableToXAndYEqY definition up here with similar cases inside TargetLoweringBase

This revision is now accepted and ready to land.Aug 4 2023, 6:04 AM
This revision was landed with ongoing or failed builds.Aug 15 2023, 11:59 PM
This revision was automatically updated to reflect the committed changes.