LoopRerollPass: Prefer Value::hasOneUse() over Value::getNumUses(). NFC.
authorZvi Rackover <zvi.rackover@intel.com>
Tue, 18 Apr 2017 14:55:43 +0000 (14:55 +0000)
committerZvi Rackover <zvi.rackover@intel.com>
Tue, 18 Apr 2017 14:55:43 +0000 (14:55 +0000)
getNumUses() can be more expensive as it iterates over all list's elements.

llvm-svn: 300558

llvm/lib/Transforms/Scalar/LoopRerollPass.cpp

index 86058fe..d54ad58 100644 (file)
@@ -557,7 +557,7 @@ bool LoopReroll::isLoopControlIV(Loop *L, Instruction *IV) {
             Instruction *UUser = dyn_cast<Instruction>(UU);
             // Skip SExt if we are extending an nsw value
             // TODO: Allow ZExt too
-            if (BO->hasNoSignedWrap() && UUser && UUser->getNumUses() == 1 &&
+            if (BO->hasNoSignedWrap() && UUser && UUser->hasOneUse() &&
                 isa<SExtInst>(UUser))
               UUser = dyn_cast<Instruction>(*(UUser->user_begin()));
             if (!isCompareUsedByBranch(UUser))