This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Replace calls to getNumUses with hasNUses or hasNUsesOrMore
ClosedPublic

Authored by craig.topper on Mar 12 2018, 11:32 AM.

Details

Summary

getNumUses is a linear time operation. It traverses the user linked list to the end and counts as it goes. Since we are only interested in small constant counts, we should use hasNUses or hasNUsesMore more that terminate the traversal as soon as it can provide the answer.

There are still two other locations in InstCombine, but changing those would force a rebase of D44266 which if accepted would remove them.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Mar 12 2018, 11:32 AM
spatel accepted this revision.Mar 12 2018, 11:45 AM

LGTM. I was going to suggest adding a note to the header doc, but I see it's already there. I'll be more careful in the future. :)
A quick grep shows there are more potential cleanups outside of instcombine.

This revision is now accepted and ready to land.Mar 12 2018, 11:45 AM
This revision was automatically updated to reflect the committed changes.