From: Max Kazantsev Date: Tue, 17 Nov 2020 07:00:37 +0000 (+0700) Subject: [NFC] Collect ext users into vector instead of finding them twice X-Git-Tag: llvmorg-13-init~5920 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63dd1734b2ed427170e1423285cc2767f6272b04;p=platform%2Fupstream%2Fllvm.git [NFC] Collect ext users into vector instead of finding them twice --- diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index f5c92a5..52f3a08 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -1568,6 +1568,7 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { // Check that all uses are either s/zext, or narrow def (in case of we are // widening the IV increment). + SmallVector ExtUsers; for (Use &U : NarrowUse->uses()) { if (U.getUser() == NarrowDef) continue; @@ -1578,6 +1579,7 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { User = dyn_cast(U.getUser()); if (!User || User->getType() != WideType) return false; + ExtUsers.push_back(User); } LLVM_DEBUG(dbgs() << "Cloning arithmetic IVUser: " << *NarrowUse << "\n"); @@ -1600,15 +1602,7 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { WideBO->copyIRFlags(NarrowBO); ExtendKindMap[NarrowUse] = ExtKind; - for (Use &U : NarrowUse->uses()) { - // Ignore narrow def: it will be removed after the transform. - if (U.getUser() == NarrowDef) - continue; - Instruction *User = nullptr; - if (ExtKind == SignExtended) - User = cast(U.getUser()); - else - User = cast(U.getUser()); + for (Instruction *User : ExtUsers) { assert(User->getType() == WideType && "Checked before!"); LLVM_DEBUG(dbgs() << "INDVARS: eliminating " << *User << " replaced by " << *WideBO << "\n");