This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Add CTPOP -> CTTZ simplifications (PR43513)
ClosedPublic

Authored by RKSimon on Mar 22 2020, 9:32 AM.

Details

Summary

As detailed on PR43513, we can simplify:

ctpop(x | -x) -> bitwidth - cttz(x, false)
Alive2: http://volta.cs.utah.edu:8080/z/caw49X

ctpop(~x & (x - 1)) -> cttz(x, false)
Alive2: http://volta.cs.utah.edu:8080/z/5zfVrx

I've tweaked the initial test cases I added at rG2d712fb75584 to increase commutativity testing, I'm happy to pre-commit these changes if you think its useful.

Diff Detail

Event Timeline

RKSimon created this revision.Mar 22 2020, 9:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2020, 9:32 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
xbolva00 accepted this revision.Mar 22 2020, 5:02 PM

Looks good

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
1340

ConstantInt::get?

This revision is now accepted and ready to land.Mar 22 2020, 5:02 PM
This revision was automatically updated to reflect the committed changes.