From 6a10b36c951a2062e83e0b7efb65bf79d3f2e615 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Thu, 11 May 2017 22:56:27 +0000 Subject: [PATCH] [VirtualInstruction] Do a lookup instead of a linear search. NFC. git-svn-id: https://llvm.org/svn/llvm-project/polly/trunk@302837 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/VirtualInstruction.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/lib/Support/VirtualInstruction.cpp b/lib/Support/VirtualInstruction.cpp index 01c92d77..e3c2cfa3 100644 --- a/lib/Support/VirtualInstruction.cpp +++ b/lib/Support/VirtualInstruction.cpp @@ -18,25 +18,6 @@ using namespace polly; using namespace llvm; -namespace { - -/// If InputVal is not defined in the stmt itself, return the MemoryAccess that -/// reads the scalar. Return nullptr otherwise (if the value is defined in the -/// scop, or is synthesizable) -MemoryAccess *getInputAccessOf(Value *InputVal, ScopStmt *UserStmt) { - for (auto *MA : *UserStmt) { - if (!MA->isRead()) - continue; - if (!MA->isOriginalValueKind()) - continue; - - if (MA->getAccessValue() == InputVal) - return MA; - } - return nullptr; -} -} // namespace - VirtualUse VirtualUse ::create(Scop *S, Use &U, LoopInfo *LI, bool Virtual) { auto *UserBB = getUseBlock(U); auto *UserStmt = S->getStmtFor(UserBB); @@ -74,7 +55,7 @@ VirtualUse VirtualUse::create(Scop *S, ScopStmt *UserStmt, Loop *UserScope, // use. This is why we look for a MemoryAccess here already. MemoryAccess *InputMA = nullptr; if (UserStmt && Virtual) - InputMA = getInputAccessOf(Val, UserStmt); + InputMA = UserStmt->lookupValueReadOf(Val); // Uses are read-only if they have been defined before the SCoP, i.e., they // cannot be written to inside the SCoP. Arguments are defined before any -- 2.11.4.GIT