OSDN Git Service

[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)
commitc4689888d647e3c22870232e98203740a98a2343
tree0eb8915d4d75d3a835c8e3a97c3a8fedef36215f
parent5ef6ff69583acedaeebb549004b7bcc4cdff5ec6
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327315 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
lib/Transforms/InstCombine/InstCombineSelect.cpp