This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Use KnownOnes to provide a better bound on known zeros for ctlz/cttz intrinics
ClosedPublic

Authored by craig.topper on Apr 25 2017, 11:02 PM.

Details

Summary

This patch uses KnownOnes of the input of ctlz/cttz to bound the value that can be returned from these intrinsics. This makes these intrinsics more similar to the handling for ctpop which already uses known bits to produce a similar bound.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 25 2017, 11:02 PM
RKSimon edited edge metadata.Apr 30 2017, 4:53 AM

Would be good if this could be added to the SelectionDAG version as well.

Rebase on top of the KnownBits struct commit

spatel added inline comments.May 8 2017, 8:01 AM
test/Transforms/InstCombine/intrinsics.ll
304–312 ↗(On Diff #97301)

Can you add a negative test for each of ctlz/cttz?
That would be "icmp eq i8 %cnt, 2" for this case if I'm reading it correctly.

Add negative tests

spatel accepted this revision.May 8 2017, 9:58 AM

LGTM.

This revision is now accepted and ready to land.May 8 2017, 9:58 AM
This revision was automatically updated to reflect the committed changes.