This is an archive of the discontinued LLVM Phabricator instance.

[X86] Make `(and/or (icmp eq/ne A,C0), (icmp eq/ne A,C1))` where `IsPow2(dif(C0,C1))` work for more patterns.
ClosedPublic

Authored by goldstein.w.n on Feb 17 2023, 10:32 AM.

Details

Summary

(and/or (icmp eq/ne A,C0), (icmp eq/ne A,C1)) can be lowered to
(icmp eq/ne (and (sub A, (smin C0, C1)), (not (sub (smax C0, C1), (smin C0, C1)))), 0)
generically if (sub (smax C0, C1), (smin C0,C1)) is a power of 2.

This covers the existing case of (and/or (icmp eq/ne A, C_Pow2),(icmp eq/ne A, -C_Pow2))
as well as other cases.

Alive2 Links:
EQ: https://alive2.llvm.org/ce/z/mLJiUW
NE: https://alive2.llvm.org/ce/z/TKnzUr

Diff Detail

Event Timeline

goldstein.w.n created this revision.Feb 17 2023, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2023, 10:32 AM
goldstein.w.n requested review of this revision.Feb 17 2023, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2023, 10:32 AM
pengfei added inline comments.Feb 19 2023, 6:56 PM
llvm/test/CodeGen/X86/icmp-pow2-dif.ll
366 ↗(On Diff #498439)

Should the name be addand? Same for below.

goldstein.w.n marked an inline comment as done.

Rebase

addadd -> addand

Comment on intentional failures

RKSimon retitled this revision from [X86] Make `(and/or (icmp eq/ne A,C0), (icmp eq/ne A,C1))` where `IsPow(dif(C0,C1))` work for more patterns. to [X86] Make `(and/or (icmp eq/ne A,C0), (icmp eq/ne A,C1))` where `IsPow2(dif(C0,C1))` work for more patterns..Feb 22 2023, 4:20 AM
RKSimon accepted this revision.Feb 23 2023, 6:12 PM

LGTM

This revision is now accepted and ready to land.Feb 23 2023, 6:12 PM
goldstein.w.n edited the summary of this revision. (Show Details)Feb 23 2023, 7:40 PM

foobar?

Was left from an earlier rebase. commit message has already been fixed.

goldstein.w.n edited the summary of this revision. (Show Details)

Rebase