For example:
int src(unsigned int a, unsigned int b) { return __builtin_popcount(a << 16) + __builtin_popcount(b >> 16); } int tgt(unsigned int a, unsigned int b) { return __builtin_popcount((a << 16) | (b >> 16)); }
Differential D101210
[InstCombine] ctpop(X) + ctpop(Y) => ctpop(X | Y) if X and Y have no common bits (PR48999) xbolva00 on Apr 23 2021, 4:47 PM. Authored by
Details For example: int src(unsigned int a, unsigned int b) { return __builtin_popcount(a << 16) + __builtin_popcount(b >> 16); } int tgt(unsigned int a, unsigned int b) { return __builtin_popcount((a << 16) | (b >> 16)); }
Diff Detail
Event Timeline
Comment Actions LGTM
|
As the pattern on both sides is the same, you don't need to use m_c_BinOp, you can just directly match LHS and RHS against ctpop.