Index: llvm/include/llvm/Transforms/Scalar/GVN.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/GVN.h +++ llvm/include/llvm/Transforms/Scalar/GVN.h @@ -45,9 +45,7 @@ class FunctionPass; class LoadInst; class LoopInfo; -class MemDepResult; class MemoryAccess; -class MemoryDependenceResults; class MemoryLocation; class MemorySSA; class MemorySSAUpdater; @@ -78,7 +76,6 @@ Optional AllowLoadPRE = None; Optional AllowLoadInLoopPRE = None; Optional AllowLoadPRESplitBackedge = None; - Optional AllowMemDep = None; Optional AllowMemorySSA = None; GVNOptions() = default; @@ -106,12 +103,6 @@ return *this; } - /// Enables or disables use of MemDepAnalysis. - GVNOptions &setMemDep(bool MemDep) { - AllowMemDep = MemDep; - return *this; - } - /// Enables or disables use of MemorySSA. GVNOptions &setMemorySSA(bool MemSSA) { AllowMemorySSA = MemSSA; @@ -146,13 +137,11 @@ DominatorTree &getDominatorTree() const { return *DT; } AAResults *getAliasAnalysis() const { return VN.getAliasAnalysis(); } - MemoryDependenceResults &getMemDep() const { return *MD; } bool isPREEnabled() const; bool isLoadPREEnabled() const; bool isLoadInLoopPREEnabled() const; bool isLoadPRESplitBackedgeEnabled() const; - bool isMemDepEnabled() const; bool isMemorySSAEnabled() const; /// This class holds the mapping between values and value numbers. It is used @@ -184,7 +173,6 @@ PhiTranslateMap PhiTranslateTable; AAResults *AA = nullptr; - MemoryDependenceResults *MD = nullptr; MemorySSA *MSSA = nullptr; DominatorTree *DT = nullptr; @@ -226,7 +214,6 @@ void erase(Value *v); void setAliasAnalysis(AAResults *A) { AA = A; } AAResults *getAliasAnalysis() const { return AA; } - void setMemDep(MemoryDependenceResults *M) { MD = M; } void setMemorySSA(MemorySSA *M) { MSSA = M; } void setDomTree(DominatorTree *D) { DT = D; } uint32_t getNextUnusedValueNumber() { return nextValueNumber; } @@ -237,7 +224,6 @@ friend class gvn::GVNLegacyPass; friend struct DenseMapInfo; - MemoryDependenceResults *MD = nullptr; DominatorTree *DT = nullptr; const TargetLibraryInfo *TLI = nullptr; AssumptionCache *AC = nullptr; @@ -280,8 +266,7 @@ using UnavailBlkVect = SmallVector; bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT, - const TargetLibraryInfo &RunTLI, AAResults &RunAA, - MemoryDependenceResults *RunMD, LoopInfo *LI, + const TargetLibraryInfo &RunTLI, AAResults &RunAA, LoopInfo *LI, OptimizationRemarkEmitter *ORE, MemorySSA *MSSA = nullptr); /// Push a new Value to the LeaderTable onto the list for its value number. @@ -370,7 +355,6 @@ // Helper functions of redundant load elimination bool processLoad(LoadInst *L); - bool processNonLocalLoad(LoadInst *L); bool processNonLocalLoad(LoadInst *L, SmallVectorImpl &Deps); bool processAssumeIntrinsic(AssumeInst *II); Index: llvm/lib/Passes/PassBuilder.cpp =================================================================== --- llvm/lib/Passes/PassBuilder.cpp +++ llvm/lib/Passes/PassBuilder.cpp @@ -780,8 +780,6 @@ Result.setLoadPRE(Enable); } else if (ParamName == "split-backedge-load-pre") { Result.setLoadPRESplitBackedge(Enable); - } else if (ParamName == "memdep") { - Result.setMemDep(Enable); } else if (ParamName == "memoryssa") { Result.setMemorySSA(Enable); } else { Index: llvm/lib/Transforms/Scalar/GVN.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVN.cpp +++ llvm/lib/Transforms/Scalar/GVN.cpp @@ -35,7 +35,6 @@ #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/MemoryBuiltins.h" -#include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/OptimizationRemarkEmitter.h" @@ -113,8 +112,7 @@ static cl::opt GVNEnableSplitBackedgeInLoadPRE("enable-split-backedge-in-load-pre", cl::init(true)); -static cl::opt GVNEnableMemDep("enable-gvn-memdep", cl::init(true)); -static cl::opt GVNEnableMemorySSA("enable-gvn-memoryssa", cl::init(false)); +static cl::opt GVNEnableMemorySSA("enable-gvn-memoryssa", cl::init(true)); static cl::opt MaxNumDeps( "gvn-max-num-deps", cl::Hidden, cl::init(100), cl::ZeroOrMore, @@ -475,101 +473,9 @@ uint32_t e = assignExpNewValueNum(exp).first; valueNumbering[C] = e; return e; - } else if (MD && AA->onlyReadsMemory(C)) { - Expression exp = createCallExpr(C); - auto ValNum = assignExpNewValueNum(exp); - if (ValNum.second) { - valueNumbering[C] = ValNum.first; - return ValNum.first; - } - - MemDepResult local_dep = MD->getDependency(C); - - if (!local_dep.isDef() && !local_dep.isNonLocal()) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - if (local_dep.isDef()) { - // For masked load/store intrinsics, the local_dep may actully be - // a normal load or store instruction. - CallInst *local_cdep = dyn_cast(local_dep.getInst()); - - if (!local_cdep || local_cdep->arg_size() != C->arg_size()) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - for (unsigned i = 0, e = C->arg_size(); i < e; ++i) { - uint32_t c_vn = lookupOrAdd(C->getArgOperand(i)); - uint32_t cd_vn = lookupOrAdd(local_cdep->getArgOperand(i)); - if (c_vn != cd_vn) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - } - - uint32_t v = lookupOrAdd(local_cdep); - valueNumbering[C] = v; - return v; - } - - // Non-local case. - const MemoryDependenceResults::NonLocalDepInfo &deps = - MD->getNonLocalCallDependency(C); - // FIXME: Move the checking logic to MemDep! - CallInst* cdep = nullptr; - - // Check to see if we have a single dominating call instruction that is - // identical to C. - for (unsigned i = 0, e = deps.size(); i != e; ++i) { - const NonLocalDepEntry *I = &deps[i]; - if (I->getResult().isNonLocal()) - continue; - - // We don't handle non-definitions. If we already have a call, reject - // instruction dependencies. - if (!I->getResult().isDef() || cdep != nullptr) { - cdep = nullptr; - break; - } - - CallInst *NonLocalDepCall = dyn_cast(I->getResult().getInst()); - // FIXME: All duplicated with non-local case. - if (NonLocalDepCall && DT->properlyDominates(I->getBB(), C->getParent())){ - cdep = NonLocalDepCall; - continue; - } - - cdep = nullptr; - break; - } - - if (!cdep) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - if (cdep->arg_size() != C->arg_size()) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - for (unsigned i = 0, e = C->arg_size(); i < e; ++i) { - uint32_t c_vn = lookupOrAdd(C->getArgOperand(i)); - uint32_t cd_vn = lookupOrAdd(cdep->getArgOperand(i)); - if (c_vn != cd_vn) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - } - - uint32_t v = lookupOrAdd(cdep); - valueNumbering[C] = v; - return v; - } else { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; } + valueNumbering[C] = nextValueNumber; + return nextValueNumber++; } uint32_t GVNPass::ValueTable::lookupOrAddLoadStore(Instruction *I) { @@ -761,10 +667,6 @@ GVNEnableSplitBackedgeInLoadPRE); } -bool GVNPass::isMemDepEnabled() const { - return Options.AllowMemDep.getValueOr(GVNEnableMemDep); -} - bool GVNPass::isMemorySSAEnabled() const { return Options.AllowMemorySSA.getValueOr(GVNEnableMemorySSA); } @@ -778,14 +680,12 @@ auto &DT = AM.getResult(F); auto &TLI = AM.getResult(F); auto &AA = AM.getResult(F); - auto *MemDep = - isMemDepEnabled() ? &AM.getResult(F) : nullptr; auto *LI = AM.getCachedResult(F); auto *MSSA = isMemorySSAEnabled() ? &AM.getResult(F) : nullptr; auto &ORE = AM.getResult(F); - bool Changed = runImpl(F, AC, DT, TLI, AA, MemDep, LI, &ORE, - MSSA ? &MSSA->getMSSA() : nullptr); + bool Changed = + runImpl(F, AC, DT, TLI, AA, LI, &ORE, MSSA ? &MSSA->getMSSA() : nullptr); if (!Changed) return PreservedAnalyses::all(); PreservedAnalyses PA; @@ -811,8 +711,6 @@ if (Options.AllowLoadPRESplitBackedge != None) OS << (Options.AllowLoadPRESplitBackedge.getValue() ? "" : "no-") << "split-backedge-load-pre;"; - if (Options.AllowMemDep != None) - OS << (Options.AllowMemDep.getValue() ? "" : "no-") << "memdep;"; if (Options.AllowMemorySSA != None) OS << (Options.AllowMemorySSA.getValue() ? "" : "no-") << "memoryssa"; OS << ">"; @@ -1047,7 +945,6 @@ // tracks. It is potentially possible to remove the load from the table, // but then there all of the operations based on it would need to be // rehashed. Just leave the dead load around. - gvn.getMemDep().removeInstruction(CoercedLoad); LLVM_DEBUG(dbgs() << "GVN COERCED NONLOCAL LOAD:\nOffset: " << Offset << " " << *getCoercedLoadValue() << '\n' << *Res << '\n' @@ -1239,20 +1136,9 @@ Load->isAtomic() <= DepLoad->isAtomic()) { Type *LoadType = Load->getType(); int Offset = Dep.Offset; - if (MD && !MSSAU) { - // If MD reported clobber, check it was nested. - if (canCoerceMustAliasedValueToLoad(DepLoad, LoadType, DL)) { - const auto ClobberOff = MD->getClobberOffset(DepLoad); - // GVN has no deal with a negative offset. - Offset = (ClobberOff == None || ClobberOff.getValue() < 0) - ? -1 - : ClobberOff.getValue(); - } - } else { - if (!canCoerceMustAliasedValueToLoad(DepLoad, LoadType, DL) || - Offset < 0) - Offset = -1; - } + if (!canCoerceMustAliasedValueToLoad(DepLoad, LoadType, DL) || + Offset < 0) + Offset = -1; if (Offset == -1) Offset = analyzeLoadFromClobberingLoad(LoadType, Address, DepLoad, DL); @@ -1446,8 +1332,6 @@ // Add the newly created load. ValuesPerBlock.push_back( AvailableValueInBlock::get(UnavailableBlock, NewLoad)); - if (MD) - MD->invalidateCachedPointerInfo(LoadPtr); LLVM_DEBUG(dbgs() << "GVN INSERTED " << *NewLoad << '\n'); } @@ -1458,8 +1342,6 @@ V->takeName(Load); if (Instruction *I = dyn_cast(V)) I->setDebugLoc(Load->getDebugLoc()); - if (MD && V->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(Load); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "LoadPRE", Load) @@ -1801,42 +1683,8 @@ /// Attempt to eliminate a load whose dependencies are /// non-local by performing PHI construction. -bool GVNPass::processNonLocalLoad(LoadInst *Load) { - // non-local speculations are not allowed under asan. - if (Load->getParent()->getParent()->hasFnAttribute( - Attribute::SanitizeAddress) || - Load->getParent()->getParent()->hasFnAttribute( - Attribute::SanitizeHWAddress)) - return false; - - // Find the non-local dependencies of the load. - LoadDepVect Deps; - MD->getNonLocalPointerDependency(Load, Deps); - - // If we had to process more than one hundred blocks to find the - // dependencies, this load isn't worth worrying about. Optimizing - // it will be too expensive. - unsigned NumDeps = Deps.size(); - if (NumDeps > MaxNumDeps) - return false; - - SmallVector MemVals; - for (const NonLocalDepResult &Dep : Deps) { - Value *Address = Dep.getAddress(); - BasicBlock *BB = Dep.getBB(); - Instruction *Inst = Dep.getResult().getInst(); - if (Dep.getResult().isClobber()) - MemVals.emplace_back(ReachingMemVal::getClobber(Address, Inst)); - else if (Dep.getResult().isDef()) - MemVals.emplace_back(ReachingMemVal::getDef(Address, Inst)); - else - MemVals.emplace_back(ReachingMemVal::getUnknown(BB, Address, Inst)); - } - return processNonLocalLoad(Load, MemVals); -} - -bool GVNPass ::processNonLocalLoad(LoadInst *Load, - SmallVectorImpl &Deps) { +bool GVNPass::processNonLocalLoad(LoadInst *Load, + SmallVectorImpl &Deps) { // If we had a phi translation failure, we'll have a single entry which is a // clobber in the current block. Reject this early. if (Deps.size() == 1 && Deps[0].Kind == DepKind::Other) { @@ -1884,8 +1732,6 @@ // to propagate Load's DebugLoc because Load may not post-dominate I. if (Load->getDebugLoc() && Load->getParent() == I->getParent()) I->setDebugLoc(Load->getDebugLoc()); - if (MD && V->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(Load); ++NumGVNLoad; reportLoadElim(Load, V, ORE); @@ -2542,7 +2388,7 @@ /// Attempt to eliminate a load, first by eliminating it /// locally, and then attempting non-local elimination if that fails. bool GVNPass::processLoad(LoadInst *L) { - if (!MD && !MSSAU) + if (!MSSAU) return false; // This code hasn't been audited for ordered or volatile memory access @@ -2554,34 +2400,14 @@ return true; } - ReachingMemVal MemVal = ReachingMemVal::getUnknown(nullptr, nullptr); - if (MD && !MSSAU) { - // ... to a pointer that has been loaded from before... - MemDepResult Dep = MD->getDependency(L); - - // If it is defined in another block, try harder. - if (Dep.isNonLocal()) - return processNonLocalLoad(L); - - // Only handle the local case below - if (Dep.isDef()) - MemVal = ReachingMemVal::getDef(L->getPointerOperand(), Dep.getInst()); - else if (Dep.isClobber()) - MemVal = - ReachingMemVal::getClobber(L->getPointerOperand(), Dep.getInst()); - } else { - SmallVector MemVals; - findReachingValuesForLoad(L, *MSSAU->getMemorySSA(), *AA, MemVals); - assert(MemVals.size() && "Expected at least an unknown value"); - if (MemVals.size() > 1 || MemVals[0].Block != L->getParent()) - return processNonLocalLoad(L, MemVals); - - // Only handle the local case below - MemVal = MemVals[0]; - } + SmallVector MemVals; + findReachingValuesForLoad(L, *MSSAU->getMemorySSA(), *AA, MemVals); + assert(MemVals.size() && "Expected at least an unknown value"); + if (MemVals.size() > 1 || MemVals[0].Block != L->getParent()) + return processNonLocalLoad(L, MemVals); Value *Address = L->getPointerOperand(); - if (MemVal.Kind == DepKind::Other && !isa(Address)) { + if (MemVals[0].Kind == DepKind::Other && !isa(Address)) { LLVM_DEBUG( // fast print dep, using operator<< on instruction is too slow. dbgs() << "GVN: load "; L->printAsOperand(dbgs()); @@ -2590,7 +2416,7 @@ } AvailableValue AV; - if (AnalyzeLoadAvailability(L, MemVal, Address, AV)) { + if (AnalyzeLoadAvailability(L, MemVals[0], Address, AV)) { Value *AvailableValue = AV.MaterializeAdjustedValue(L, L, *this); // Replace the load! @@ -2600,10 +2426,6 @@ MSSAU->removeMemoryAccess(L); ++NumGVNLoad; reportLoadElim(L, AvailableValue, ORE); - // Tell MDA to reexamine the reused pointer since we might have more - // information after forwarding it. - if (MD && AvailableValue->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(AvailableValue); return true; } @@ -2663,25 +2485,7 @@ Vals = Vals->Next; } - if (AA->doesNotAccessMemory(Call)) - return true; - - if (!MD || !AA->onlyReadsMemory(Call)) - return false; - - MemDepResult local_dep = MD->getDependency(Call); - if (!local_dep.isNonLocal()) - return false; - - const MemoryDependenceResults::NonLocalDepInfo &deps = - MD->getNonLocalCallDependency(Call); - - // Check to see if the Call has no function local clobber. - for (const NonLocalDepEntry &D : deps) { - if (D.getResult().isNonFuncLocal()) - return true; - } - return false; + return AA->doesNotAccessMemory(Call); } /// Translate value number \p Num using phis, so that it has the values of @@ -2910,9 +2714,6 @@ Changed |= NumReplacements > 0; NumGVNEqProp += NumReplacements; - // Cached information for anything that uses LHS will be invalid. - if (MD) - MD->invalidateCachedPointerInfo(LHS); } // Now try to deduce additional equalities from this one. For example, if @@ -2973,9 +2774,6 @@ Root.getStart()); Changed |= NumReplacements > 0; NumGVNEqProp += NumReplacements; - // Cached information for anything that uses NotCmp will be invalid. - if (MD) - MD->invalidateCachedPointerInfo(NotCmp); } } // Ensure that any instruction in scope that gets the "A < B" value number @@ -3018,8 +2816,6 @@ Changed = true; } if (Changed) { - if (MD && V->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(V); ++NumGVNSimpl; return true; } @@ -3128,8 +2924,6 @@ // Remove it! patchAndReplaceAllUsesWith(I, Repl); - if (MD && Repl->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(Repl); markInstructionForDeletion(I); return true; } @@ -3137,19 +2931,17 @@ /// runOnFunction - This is the main transformation entry point for a function. bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT, const TargetLibraryInfo &RunTLI, AAResults &RunAA, - MemoryDependenceResults *RunMD, LoopInfo *LI, - OptimizationRemarkEmitter *RunORE, MemorySSA *MSSA) { + LoopInfo *LI, OptimizationRemarkEmitter *RunORE, + MemorySSA *MSSA) { AC = &RunAC; DT = &RunDT; VN.setDomTree(DT); TLI = &RunTLI; AA = &RunAA; VN.setAliasAnalysis(&RunAA); - MD = RunMD; ImplicitControlFlowTracking ImplicitCFT; ICF = &ImplicitCFT; this->LI = LI; - VN.setMemDep(MD); VN.setMemorySSA(MSSA); ORE = RunORE; InvalidBlockRPONumbers = true; @@ -3163,7 +2955,7 @@ // Merge unconditional branches, allowing PRE to catch more // optimization opportunities. for (BasicBlock &BB : llvm::make_early_inc_range(F)) { - bool removedBlock = MergeBlockIntoPredecessor(&BB, &DTU, LI, MSSAU, MD); + bool removedBlock = MergeBlockIntoPredecessor(&BB, &DTU, LI, MSSAU, nullptr); if (removedBlock) ++NumGVNBlocks; @@ -3247,7 +3039,6 @@ LLVM_DEBUG(dbgs() << "GVN removed: " << *I << '\n'); salvageKnowledge(I, AC); salvageDebugInfo(*I); - if (MD) MD->removeInstruction(I); if (MSSAU) MSSAU->removeMemoryAccess(I); LLVM_DEBUG(verifyRemoved(I)); @@ -3478,14 +3269,10 @@ addToLeaderTable(ValNo, Phi, CurrentBlock); Phi->setDebugLoc(CurInst->getDebugLoc()); CurInst->replaceAllUsesWith(Phi); - if (MD && Phi->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(Phi); VN.erase(CurInst); removeFromLeaderTable(ValNo, CurInst, CurrentBlock); LLVM_DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n'); - if (MD) - MD->removeInstruction(CurInst); if (MSSAU) MSSAU->removeMemoryAccess(CurInst); LLVM_DEBUG(verifyRemoved(CurInst)); @@ -3533,11 +3320,8 @@ BasicBlock *BB = SplitCriticalEdge( Pred, Succ, CriticalEdgeSplittingOptions(DT, LI, MSSAU).unsetPreserveLoopSimplify()); - if (BB) { - if (MD) - MD->invalidateCachedPredecessors(); + if (BB) InvalidBlockRPONumbers = true; - } return BB; } @@ -3554,11 +3338,8 @@ CriticalEdgeSplittingOptions(DT, LI, MSSAU)) != nullptr; } while (!toSplit.empty()); - if (Changed) { - if (MD) - MD->invalidateCachedPredecessors(); + if (Changed) InvalidBlockRPONumbers = true; - } return Changed; } @@ -3676,11 +3457,8 @@ for (BasicBlock *P : predecessors(B)) { if (!DeadBlocks.count(P)) continue; - for (PHINode &Phi : B->phis()) { + for (PHINode &Phi : B->phis()) Phi.setIncomingValueForBlock(P, PoisonValue::get(Phi.getType())); - if (MD) - MD->invalidateCachedPointerInfo(&Phi); - } } } } @@ -3739,11 +3517,8 @@ public: static char ID; // Pass identification, replacement for typeid - explicit GVNLegacyPass(bool MemDepAnalysis = GVNEnableMemDep, - bool MemSSAAnalysis = GVNEnableMemorySSA) - : FunctionPass(ID), Impl(GVNOptions() - .setMemDep(MemDepAnalysis) - .setMemorySSA(MemSSAAnalysis)) { + explicit GVNLegacyPass(bool MemSSAAnalysis = GVNEnableMemorySSA) + : FunctionPass(ID), Impl(GVNOptions().setMemorySSA(MemSSAAnalysis)) { initializeGVNLegacyPassPass(*PassRegistry::getPassRegistry()); } @@ -3757,9 +3532,6 @@ getAnalysis().getDomTree(), getAnalysis().getTLI(F), getAnalysis().getAAResults(), - Impl.isMemDepEnabled() - ? &getAnalysis().getMemDep() - : nullptr, LIWP ? &LIWP->getLoopInfo() : nullptr, &getAnalysis().getORE(), Impl.isMemorySSAEnabled() @@ -3772,8 +3544,6 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); - if (Impl.isMemDepEnabled()) - AU.addRequired(); if (Impl.isMemorySSAEnabled()) AU.addRequired(); AU.addRequired(); @@ -3794,7 +3564,6 @@ INITIALIZE_PASS_BEGIN(GVNLegacyPass, "gvn", "Global Value Numbering", false, false) INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -43,7 +43,6 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/IteratedDominanceFrontier.h" -#include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/PostDominators.h" @@ -259,8 +258,8 @@ class GVNHoist { public: GVNHoist(DominatorTree *DT, PostDominatorTree *PDT, AliasAnalysis *AA, - MemoryDependenceResults *MD, MemorySSA *MSSA) - : DT(DT), PDT(PDT), AA(AA), MD(MD), MSSA(MSSA), + MemorySSA *MSSA) + : DT(DT), PDT(PDT), AA(AA), MSSA(MSSA), MSSAUpdater(std::make_unique(MSSA)) {} bool run(Function &F); @@ -278,7 +277,6 @@ DominatorTree *DT; PostDominatorTree *PDT; AliasAnalysis *AA; - MemoryDependenceResults *MD; MemorySSA *MSSA; std::unique_ptr MSSAUpdater; DenseMap DFSNumber; @@ -531,10 +529,9 @@ auto &DT = getAnalysis().getDomTree(); auto &PDT = getAnalysis().getPostDomTree(); auto &AA = getAnalysis().getAAResults(); - auto &MD = getAnalysis().getMemDep(); auto &MSSA = getAnalysis().getMSSA(); - GVNHoist G(&DT, &PDT, &AA, &MD, &MSSA); + GVNHoist G(&DT, &PDT, &AA, &MSSA); return G.run(F); } @@ -542,7 +539,6 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); - AU.addRequired(); AU.addRequired(); AU.addPreserved(); AU.addPreserved(); @@ -554,7 +550,6 @@ NumFuncArgs = F.arg_size(); VN.setDomTree(DT); VN.setAliasAnalysis(AA); - VN.setMemDep(MD); bool Res = false; // Perform DFS Numbering of instructions. unsigned BBI = 0; @@ -1020,8 +1015,6 @@ Repl->andIRFlags(I); combineKnownMetadata(Repl, I); I->replaceAllUsesWith(Repl); - // Also invalidate the Alias Analysis cache. - MD->removeInstruction(I); I->eraseFromParent(); } } @@ -1141,7 +1134,6 @@ // Move the instruction at the end of HoistPt. Instruction *Last = DestBB->getTerminator(); - MD->removeInstruction(Repl); Repl->moveBefore(Last); DFSNumber[Repl] = DFSNumber[Last]++; @@ -1236,9 +1228,8 @@ DominatorTree &DT = AM.getResult(F); PostDominatorTree &PDT = AM.getResult(F); AliasAnalysis &AA = AM.getResult(F); - MemoryDependenceResults &MD = AM.getResult(F); MemorySSA &MSSA = AM.getResult(F).getMSSA(); - GVNHoist G(&DT, &PDT, &AA, &MD, &MSSA); + GVNHoist G(&DT, &PDT, &AA, &MSSA); if (!G.run(F)) return PreservedAnalyses::all(); @@ -1252,7 +1243,6 @@ INITIALIZE_PASS_BEGIN(GVNHoistLegacyPass, "gvn-hoist", "Early GVN Hoisting of Expressions", false, false) -INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass) Index: llvm/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll =================================================================== --- llvm/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll +++ llvm/test/Analysis/TypeBasedAliasAnalysis/gvn-nonlocal-type-mismatch.ll @@ -1,5 +1,4 @@ -; RUN: opt -tbaa -basic-aa -gvn -S -enable-gvn-memoryssa=false < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MEMDEP -; RUN: opt -tbaa -basic-aa -gvn -S -enable-gvn-memoryssa=true < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MEMSSA +; RUN: opt -tbaa -basic-aa -gvn -S < %s | FileCheck %s --check-prefixes=CHECK target datalayout = "e-p:64:64:64" @@ -40,10 +39,8 @@ ; CHECK: store i32 %t, i32* %q ; CHECK: ret void ; CHECK: if.else: -; CHECK-MEMDEP-NEXT: %u = load i32, i32* %p -; CHECK-MEMDEP-NEXT: store i32 %u, i32* %q -; CHECK-MEMSSA-NEXT: store i32 0, i32* %q -; CHECK-MEMSSA-NEXT: ret void +; CHECK-NEXT: store i32 0, i32* %q +; CHECK-NEXT: ret void define void @watch_out_for_type_change(i1 %c, i32* %p, i32* %p1, i32* %q) nounwind { entry: Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -9,7 +9,7 @@ ; RUN: | grep -v 'Verify generated machine code' | FileCheck -match-full-lines -strict-whitespace -check-prefix=GCN-O1-OPTS %s ; RUN: llc -O2 -mtriple=amdgcn--amdhsa -disable-verify -debug-pass=Structure < %s 2>&1 \ ; RUN: | grep -v 'Verify generated machine code' | FileCheck -match-full-lines -strict-whitespace -check-prefix=GCN-O2 %s -; RUN: llc -O3 -mtriple=amdgcn--amdhsa -disable-verify -debug-pass=Structure -enable-gvn-memoryssa=false < %s 2>&1 \ +; RUN: llc -O3 -mtriple=amdgcn--amdhsa -disable-verify -debug-pass=Structure < %s 2>&1 \ ; RUN: | grep -v 'Verify generated machine code' | FileCheck -match-full-lines -strict-whitespace -check-prefix=GCN-O3 %s ; REQUIRES: asserts @@ -1024,9 +1024,8 @@ ; GCN-O3-NEXT: Speculatively execute instructions ; GCN-O3-NEXT: Scalar Evolution Analysis ; GCN-O3-NEXT: Straight line strength reduction -; GCN-O3-NEXT: Phi Values Analysis ; GCN-O3-NEXT: Function Alias Analysis Results -; GCN-O3-NEXT: Memory Dependence Analysis +; GCN-O3-NEXT: Memory SSA ; GCN-O3-NEXT: Optimization Remark Emitter ; GCN-O3-NEXT: Global Value Numbering ; GCN-O3-NEXT: Scalar Evolution Analysis @@ -1062,10 +1061,9 @@ ; GCN-O3-NEXT: Scalarize Masked Memory Intrinsics ; GCN-O3-NEXT: Expand reduction intrinsics ; GCN-O3-NEXT: Natural Loop Information -; GCN-O3-NEXT: Phi Values Analysis ; GCN-O3-NEXT: Basic Alias Analysis (stateless AA impl) ; GCN-O3-NEXT: Function Alias Analysis Results -; GCN-O3-NEXT: Memory Dependence Analysis +; GCN-O3-NEXT: Memory SSA ; GCN-O3-NEXT: Lazy Branch Probability Analysis ; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: Optimization Remark Emitter Index: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/opt-pipeline.ll +++ llvm/test/CodeGen/AMDGPU/opt-pipeline.ll @@ -1,7 +1,7 @@ ; RUN: opt -O0 -mtriple=amdgcn--amdhsa -disable-output -disable-verify -debug-pass=Structure -enable-new-pm=0 %s 2>&1 | FileCheck -check-prefix=GCN-O0 %s ; RUN: opt -O1 -mtriple=amdgcn--amdhsa -disable-output -disable-verify -debug-pass=Structure -enable-new-pm=0 %s 2>&1 | FileCheck -check-prefix=GCN-O1 %s -; RUN: opt -O2 -mtriple=amdgcn--amdhsa -disable-output -disable-verify -debug-pass=Structure -enable-new-pm=0 -enable-gvn-memoryssa=false %s 2>&1 | FileCheck -check-prefix=GCN-O2 %s -; RUN: opt -O3 -mtriple=amdgcn--amdhsa -disable-output -disable-verify -debug-pass=Structure -enable-new-pm=0 -enable-gvn-memoryssa=false %s 2>&1 | FileCheck -check-prefix=GCN-O3 %s +; RUN: opt -O2 -mtriple=amdgcn--amdhsa -disable-output -disable-verify -debug-pass=Structure -enable-new-pm=0 %s 2>&1 | FileCheck -check-prefix=GCN-O2 %s +; RUN: opt -O3 -mtriple=amdgcn--amdhsa -disable-output -disable-verify -debug-pass=Structure -enable-new-pm=0 %s 2>&1 | FileCheck -check-prefix=GCN-O3 %s ; REQUIRES: asserts @@ -495,9 +495,8 @@ ; GCN-O2-NEXT: SROA ; GCN-O2-NEXT: Function Alias Analysis Results ; GCN-O2-NEXT: MergedLoadStoreMotion -; GCN-O2-NEXT: Phi Values Analysis ; GCN-O2-NEXT: Function Alias Analysis Results -; GCN-O2-NEXT: Memory Dependence Analysis +; GCN-O2-NEXT: Memory SSA ; GCN-O2-NEXT: Lazy Branch Probability Analysis ; GCN-O2-NEXT: Lazy Block Frequency Analysis ; GCN-O2-NEXT: Optimization Remark Emitter @@ -859,9 +858,8 @@ ; GCN-O3-NEXT: SROA ; GCN-O3-NEXT: Function Alias Analysis Results ; GCN-O3-NEXT: MergedLoadStoreMotion -; GCN-O3-NEXT: Phi Values Analysis ; GCN-O3-NEXT: Function Alias Analysis Results -; GCN-O3-NEXT: Memory Dependence Analysis +; GCN-O3-NEXT: Memory SSA ; GCN-O3-NEXT: Lazy Branch Probability Analysis ; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: Optimization Remark Emitter Index: llvm/test/Other/new-pm-defaults.ll =================================================================== --- llvm/test/Other/new-pm-defaults.ll +++ llvm/test/Other/new-pm-defaults.ll @@ -185,8 +185,6 @@ ; CHECK-MATRIX: Running pass: VectorCombinePass ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O23SZ-NEXT: Running pass: GVNPass -; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O23SZ-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O1-NEXT: Running pass: MemCpyOptPass ; CHECK-O-NEXT: Running pass: SCCPPass ; CHECK-O-NEXT: Running pass: BDCEPass Index: llvm/test/Other/new-pm-lto-defaults.ll =================================================================== --- llvm/test/Other/new-pm-lto-defaults.ll +++ llvm/test/Other/new-pm-lto-defaults.ll @@ -98,8 +98,6 @@ ; CHECK-O23SZ-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O23SZ-NEXT: Running pass: LICMPass on Loop ; CHECK-O23SZ-NEXT: Running pass: GVNPass on foo -; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis on foo -; CHECK-O23SZ-NEXT: Running analysis: PhiValuesAnalysis on foo ; CHECK-O23SZ-NEXT: Running pass: MemCpyOptPass on foo ; CHECK-O23SZ-NEXT: Running pass: DSEPass on foo ; CHECK-O23SZ-NEXT: Running analysis: PostDominatorTreeAnalysis on foo Index: llvm/test/Other/new-pm-print-pipeline.ll =================================================================== --- llvm/test/Other/new-pm-print-pipeline.ll +++ llvm/test/Other/new-pm-print-pipeline.ll @@ -34,8 +34,8 @@ ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-unroll<>,loop-unroll,loop-unroll)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-10 ; CHECK-10: function(loop-unroll,loop-unroll,loop-unroll) -; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(gvn<>,gvn,gvn)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-11 -; CHECK-11: function(gvn<>,gvn,gvn) +; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(gvn<>,gvn,gvn)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-11 +; CHECK-11: function(gvn<>,gvn,gvn) ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(early-cse<>,early-cse)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-12 ; CHECK-12: function(early-cse<>,early-cse) Index: llvm/test/Other/new-pm-thinlto-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-defaults.ll +++ llvm/test/Other/new-pm-thinlto-defaults.ll @@ -148,20 +148,12 @@ ; CHECK-O-NEXT: Running pass: SROAPass on foo ; CHECK-Os-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Os-NEXT: Running pass: GVNPass -; CHECK-Os-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Os-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-Oz-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Oz-NEXT: Running pass: GVNPass -; CHECK-Oz-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Oz-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O2-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O2-NEXT: Running pass: GVNPass -; CHECK-O2-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O2-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O3-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O3-NEXT: Running pass: GVNPass -; CHECK-O3-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O3-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O1-NEXT: Running pass: MemCpyOptPass ; CHECK-O-NEXT: Running pass: SCCPPass ; CHECK-O-NEXT: Running pass: BDCEPass Index: llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll @@ -121,20 +121,12 @@ ; CHECK-O-NEXT: Running pass: SROAPass on foo ; CHECK-Os-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Os-NEXT: Running pass: GVNPass -; CHECK-Os-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Os-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-Oz-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Oz-NEXT: Running pass: GVNPass -; CHECK-Oz-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Oz-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O2-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O2-NEXT: Running pass: GVNPass -; CHECK-O2-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O2-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O3-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O3-NEXT: Running pass: GVNPass -; CHECK-O3-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O3-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O1-NEXT: Running pass: MemCpyOptPass ; CHECK-O-NEXT: Running pass: SCCPPass ; CHECK-O-NEXT: Running pass: BDCEPass Index: llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll @@ -130,20 +130,12 @@ ; CHECK-O-NEXT: Running pass: SROAPass on foo ; CHECK-Os-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Os-NEXT: Running pass: GVNPass -; CHECK-Os-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Os-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-Oz-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Oz-NEXT: Running pass: GVNPass -; CHECK-Oz-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Oz-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O2-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O2-NEXT: Running pass: GVNPass -; CHECK-O2-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O2-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O3-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O3-NEXT: Running pass: GVNPass -; CHECK-O3-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O3-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O1-NEXT: Running pass: MemCpyOptPass ; CHECK-O-NEXT: Running pass: SCCPPass ; CHECK-O-NEXT: Running pass: BDCEPass Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll @@ -159,20 +159,12 @@ ; CHECK-O-NEXT: Running pass: SROAPass on foo ; CHECK-Os-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Os-NEXT: Running pass: GVNPass -; CHECK-Os-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Os-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-Oz-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Oz-NEXT: Running pass: GVNPass -; CHECK-Oz-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Oz-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O2-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O2-NEXT: Running pass: GVNPass -; CHECK-O2-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O2-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O3-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O3-NEXT: Running pass: GVNPass -; CHECK-O3-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O3-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O1-NEXT: Running pass: MemCpyOptPass ; CHECK-O-NEXT: Running pass: SCCPPass ; CHECK-O-NEXT: Running pass: BDCEPass Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll @@ -124,20 +124,12 @@ ; CHECK-O-NEXT: Running pass: SROAPass on foo ; CHECK-Os-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Os-NEXT: Running pass: GVNPass -; CHECK-Os-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Os-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-Oz-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-Oz-NEXT: Running pass: GVNPass -; CHECK-Oz-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-Oz-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O2-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O2-NEXT: Running pass: GVNPass -; CHECK-O2-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O2-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O3-NEXT: Running pass: MergedLoadStoreMotionPass ; CHECK-O3-NEXT: Running pass: GVNPass -; CHECK-O3-NEXT: Running analysis: MemoryDependenceAnalysis -; CHECK-O3-NEXT: Running analysis: PhiValuesAnalysis ; CHECK-O1-NEXT: Running pass: MemCpyOptPass ; CHECK-O-NEXT: Running pass: SCCPPass ; CHECK-O-NEXT: Running pass: BDCEPass Index: llvm/test/Transforms/GVN/PRE/rle.ll =================================================================== --- llvm/test/Transforms/GVN/PRE/rle.ll +++ llvm/test/Transforms/GVN/PRE/rle.ll @@ -1,7 +1,5 @@ -; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -enable-gvn-memoryssa=false -S -dce | FileCheck %s --check-prefixes=CHECK,LE,LE-MEMDEP -; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -enable-gvn-memoryssa=true -S -dce | FileCheck %s --check-prefixes=CHECK,LE,LE-MEMSSA -; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32" -basic-aa -gvn -enable-gvn-memoryssa=false -S -dce | FileCheck %s --check-prefixes=CHECK,BE,BE-MEMDEP -; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32" -basic-aa -gvn -enable-gvn-memoryssa=true -S -dce | FileCheck %s --check-prefixes=CHECK,BE,BE-MEMSSA +; RUN: opt < %s -data-layout="e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-n8:16:32" -basic-aa -gvn -S -dce | FileCheck %s --check-prefixes=CHECK,LE +; RUN: opt < %s -data-layout="E-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-n32" -basic-aa -gvn -S -dce | FileCheck %s --check-prefixes=CHECK,BE ;; Trivial RLE test. define i32 @test0(i32 %V, i32* %P) { @@ -1015,15 +1013,11 @@ ; CHECK-NEXT: [[XX:%.*]] = bitcast i8* [[P:%.*]] to i32* ; CHECK-NEXT: [[X1:%.*]] = load i32, i32* [[XX]], align 4 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X1]], 127 -; LE-MEMDEP-NEXT: [[TMP0:%.*]] = lshr i32 [[X1]], 16 -; BE-MEMDEP-NEXT: [[TMP0:%.*]] = lshr i32 [[X1]], 8 -; LE-MEMSSA-NEXT: [[TMP0:%.*]] = lshr i32 [[X1]], 8 -; BE-MEMSSA-NEXT: [[TMP0:%.*]] = lshr i32 [[X1]], 16 +; LE-NEXT: [[TMP0:%.*]] = lshr i32 [[X1]], 8 +; BE-NEXT: [[TMP0:%.*]] = lshr i32 [[X1]], 16 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[TMP0]] to i8 -; LE-MEMDEP-NEXT: [[TMP2:%.*]] = lshr i32 [[X1]], 8 -; BE-MEMDEP-NEXT: [[TMP2:%.*]] = lshr i32 [[X1]], 16 -; LE-MEMSSA-NEXT: [[TMP2:%.*]] = lshr i32 [[X1]], 16 -; BE-MEMSSA-NEXT: [[TMP2:%.*]] = lshr i32 [[X1]], 8 +; LE-NEXT: [[TMP2:%.*]] = lshr i32 [[X1]], 16 +; BE-NEXT: [[TMP2:%.*]] = lshr i32 [[X1]], 8 ; CHECK-NEXT: [[TMP3:%.*]] = trunc i32 [[TMP2]] to i8 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]] ; CHECK: if: @@ -1031,10 +1025,8 @@ ; CHECK: else: ; CHECK-NEXT: br label [[JOIN]] ; CHECK: join: -; LE-MEMDEP-NEXT: [[TTMP5:%.*]] = phi i8 [ [[TMP3]], [[IF]] ], [ [[TMP1]], [[ELSE]] ] -; BE-MEMDEP-NEXT: [[TTMP5:%.*]] = phi i8 [ [[TMP3]], [[IF]] ], [ [[TMP1]], [[ELSE]] ] -; LE-MEMSSA-NEXT: [[TTMP5:%.*]] = phi i8 [ [[TMP1]], [[IF]] ], [ [[TMP3]], [[ELSE]] ] -; BE-MEMSSA-NEXT: [[TTMP5:%.*]] = phi i8 [ [[TMP1]], [[IF]] ], [ [[TMP3]], [[ELSE]] ] +; LE-NEXT: [[TTMP5:%.*]] = phi i8 [ [[TMP1]], [[IF]] ], [ [[TMP3]], [[ELSE]] ] +; BE-NEXT: [[TTMP5:%.*]] = phi i8 [ [[TMP1]], [[IF]] ], [ [[TMP3]], [[ELSE]] ] ; CHECK-NEXT: [[CONV6:%.*]] = zext i8 [[TTMP5]] to i32 ; CHECK-NEXT: ret i32 [[CONV6]] ; CHECK: if.end: Index: llvm/test/Transforms/GVN/no-mem-dep-info.ll =================================================================== --- llvm/test/Transforms/GVN/no-mem-dep-info.ll +++ llvm/test/Transforms/GVN/no-mem-dep-info.ll @@ -1,5 +1,5 @@ -; RUN: opt %s -gvn -S -enable-gvn-memdep=false | FileCheck %s -; RUN: opt %s -gvn -S -enable-gvn-memdep=true | FileCheck %s +; RUN: opt %s -gvn -S -enable-gvn-memoryssa=false | FileCheck %s +; RUN: opt %s -gvn -S -enable-gvn-memoryssa=true | FileCheck %s ; Check that llvm.x86.avx2.gather.d.ps.256 intrinsic is not eliminated by GVN ; with and without memory dependence info. Index: llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll =================================================================== --- llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll +++ llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll @@ -1,13 +1,13 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false | FileCheck %s --check-prefix=O1 -; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false | FileCheck %s --check-prefix=O2 -; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-threshold=150 -unroll-allow-partial=0 -enable-gvn-memoryssa=false | FileCheck %s --check-prefix=O3 -; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false| FileCheck %s --check-prefix=O3DEFAULT -; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false| FileCheck %s --check-prefix=Os -; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false| FileCheck %s --check-prefix=Oz -; RUN: opt < %s -mcpu=corei7 -passes='default,loop-vectorize' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false | FileCheck %s --check-prefix=O1VEC2 -; RUN: opt < %s -mcpu=corei7 -passes='default,loop-vectorize' -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false | FileCheck %s --check-prefix=OzVEC2 -; RUN: opt < %s -mcpu=corei7 -passes='default' -unroll-threshold=150 -vectorize-loops=false -S -unroll-allow-partial=0 -enable-gvn-memoryssa=false | FileCheck %s --check-prefix=O3DIS +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O2 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-threshold=150 -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3 +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DEFAULT +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Os +; RUN: opt < %s -mcpu=corei7 -passes='default' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Oz +; RUN: opt < %s -mcpu=corei7 -passes='default,loop-vectorize' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1VEC2 +; RUN: opt < %s -mcpu=corei7 -passes='default,loop-vectorize' -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC2 +; RUN: opt < %s -mcpu=corei7 -passes='default' -unroll-threshold=150 -vectorize-loops=false -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DIS ; This file tests the llvm.loop.vectorize.enable metadata forcing ; vectorization even when optimization levels are too low, or when @@ -1850,7 +1850,7 @@ ; O3DEFAULT-NEXT: [[TMP47:%.*]] = add nsw <4 x i32> [[TMP46]], [[SHUFFLE]] ; O3DEFAULT-NEXT: [[TMP48:%.*]] = bitcast i32* [[ARRAYIDX2_44]] to <4 x i32>* ; O3DEFAULT-NEXT: store <4 x i32> [[TMP47]], <4 x i32>* [[TMP48]], align 4 -; O3DEFAULT-NEXT: [[TMP49:%.*]] = load i32, i32* [[A]], align 4 +; O3DEFAULT-NEXT: [[TMP49:%.*]] = extractelement <4 x i32> [[TMP3]], i64 0 ; O3DEFAULT-NEXT: ret i32 [[TMP49]] ; ; Os-LABEL: @disabled(