[InstCombine] Replace calls to getNumUses with hasNUses or hasNUsesOrMore
authorCraig Topper <craig.topper@intel.com>
Mon, 12 Mar 2018 18:46:05 +0000 (18:46 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 12 Mar 2018 18:46:05 +0000 (18:46 +0000)
commitee99aa4dd086b907bf4552f5b368a73e5f087655
tree7a4bb18472ebefa218ea14a4ac9b11fbf0de289c
parent3b4ad9c12d2e0c4ac67b2f0661aa0072dd0b64cb
[InstCombine] Replace calls to getNumUses with hasNUses or hasNUsesOrMore

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.

Differential Revision: https://reviews.llvm.org/D44398

llvm-svn: 327315
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp