Page MenuHomePhabricator

[InstCombine] ctpop(X) ^ ctpop(Y) & 1 --> ctpop(X^Y) & 1 (PR50094)
ClosedPublic

Authored by xbolva00 on Mon, May 3, 5:04 PM.

Details

Summary

Original pattern: (builtin_parity(x) ^ builtin_parity(y))

LLVM rewrites it as: (builtin_popcount(x) ^ builtin_popcount(y)) & 1

Optimized form: __builtin_popcount(X^Y) & 1

Alive proof: https://alive2.llvm.org/ce/z/-GdWFr

Diff Detail

Event Timeline

xbolva00 created this revision.Mon, May 3, 5:04 PM
xbolva00 requested review of this revision.Mon, May 3, 5:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMon, May 3, 5:04 PM
RKSimon accepted this revision.Tue, May 4, 4:01 AM

LGTM with one minor

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
227
// (ctpop(X) ^ ctpop(Y)) & 1 --> ctpop(X^Y) & 1
This revision is now accepted and ready to land.Tue, May 4, 4:01 AM
xbolva00 added inline comments.Tue, May 4, 4:13 AM
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
227

Yeah, thx