This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Use known ones to provide a better bound for the known zeros for CTTZ/CTLZ operations.
ClosedPublic

Authored by craig.topper on Apr 30 2017, 11:54 PM.

Details

Summary

This is the SelectionDAG version of D32521. If know where at least one 1 is located in the input to these intrinsics we can place an upper bound on the number of bits needed to represent the count and thus increase the number of known zeros in the output.

I think we can also refine this further for CTTZ_UNDEF/CTLZ_UNDEF by assuming that the answer will never be BitWidth. I've left this out for now because it caused other test failures across multiple targets. Usually because of turning ADD into OR based on this new information.

I'll fix CTPOP in a future patch.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 30 2017, 11:54 PM
RKSimon accepted this revision.May 1 2017, 6:02 AM

LGTM

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2386 ↗(On Diff #97260)

clang-format?

2395 ↗(On Diff #97260)

clang-format?

This revision is now accepted and ready to land.May 1 2017, 6:02 AM
This revision was automatically updated to reflect the committed changes.