From 1440f53307347d3f3ee6da62b21e00cfd4cc968a Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Mon, 7 Dec 2015 21:41:29 +0000 Subject: [PATCH] Revert 254950 It's causing test failures on AArch64. Due to a bad build config on my part, I apparently wasn't running the tests I thought I was. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254954 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/EarlyCSE.cpp | 89 +++++++++++++++--------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/lib/Transforms/Scalar/EarlyCSE.cpp b/lib/Transforms/Scalar/EarlyCSE.cpp index 4c28d4bc5f7..b055044ba6d 100644 --- a/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/lib/Transforms/Scalar/EarlyCSE.cpp @@ -388,58 +388,57 @@ private: class ParseMemoryInst { public: ParseMemoryInst(Instruction *Inst, const TargetTransformInfo &TTI) - : IsTargetMemInst(false), Inst(Inst) { - if (IntrinsicInst *II = dyn_cast(Inst)) - if (TTI.getTgtMemIntrinsic(II, Info) && Info.NumMemRefs == 1) - IsTargetMemInst = true; - } - bool isLoad() const { - if (IsTargetMemInst) return Info.ReadMem; - return isa(Inst); - } - bool isStore() const { - if (IsTargetMemInst) return Info.WriteMem; - return isa(Inst); - } - bool isSimple() const { - if (IsTargetMemInst) return Info.IsSimple; - if (LoadInst *LI = dyn_cast(Inst)) { - return LI->isSimple(); + : Load(false), Store(false), IsSimple(true), MayReadFromMemory(false), + MayWriteToMemory(false), MatchingId(-1), Ptr(nullptr) { + MayReadFromMemory = Inst->mayReadFromMemory(); + MayWriteToMemory = Inst->mayWriteToMemory(); + if (IntrinsicInst *II = dyn_cast(Inst)) { + MemIntrinsicInfo Info; + if (!TTI.getTgtMemIntrinsic(II, Info)) + return; + if (Info.NumMemRefs == 1) { + Store = Info.WriteMem; + Load = Info.ReadMem; + MatchingId = Info.MatchingId; + MayReadFromMemory = Info.ReadMem; + MayWriteToMemory = Info.WriteMem; + IsSimple = Info.IsSimple; + Ptr = Info.PtrVal; + } + } else if (LoadInst *LI = dyn_cast(Inst)) { + Load = true; + IsSimple = LI->isSimple(); + Ptr = LI->getPointerOperand(); } else if (StoreInst *SI = dyn_cast(Inst)) { - return SI->isSimple(); + Store = true; + IsSimple = SI->isSimple(); + Ptr = SI->getPointerOperand(); } - return Inst->isAtomic(); } + bool isLoad() const { return Load; } + bool isStore() const { return Store; } + bool isSimple() const { return IsSimple; } bool isMatchingMemLoc(const ParseMemoryInst &Inst) const { - return (getPointerOperand() == Inst.getPointerOperand() && - getMatchingId() == Inst.getMatchingId()); + return Ptr == Inst.Ptr && MatchingId == Inst.MatchingId; } - bool isValid() const { return getPointerOperand() != nullptr; } + bool isValid() const { return Ptr != nullptr; } + int getMatchingId() const { return MatchingId; } + Value *getPtr() const { return Ptr; } + bool mayReadFromMemory() const { return MayReadFromMemory; } + bool mayWriteToMemory() const { return MayWriteToMemory; } + private: + bool Load; + bool Store; + bool IsSimple; + bool MayReadFromMemory; + bool MayWriteToMemory; // For regular (non-intrinsic) loads/stores, this is set to -1. For // intrinsic loads/stores, the id is retrieved from the corresponding // field in the MemIntrinsicInfo structure. That field contains // non-negative values only. - int getMatchingId() const { - if (IsTargetMemInst) return Info.MatchingId; - return -1; - } - Value *getPointerOperand() const { - if (IsTargetMemInst) return Info.PtrVal; - if (LoadInst *LI = dyn_cast(Inst)) { - return LI->getPointerOperand(); - } else if (StoreInst *SI = dyn_cast(Inst)) { - return SI->getPointerOperand(); - } - return nullptr; - } - bool mayReadFromMemory() const { return Inst->mayReadFromMemory(); } - bool mayWriteToMemory() const { return Inst->mayWriteToMemory(); } - - private: - bool IsTargetMemInst; - MemIntrinsicInfo Info; - Instruction *Inst; + int MatchingId; + Value *Ptr; }; bool processNode(DomTreeNode *Node); @@ -566,7 +565,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { // If we have an available version of this load, and if it is the right // generation, replace this instruction. - LoadValue InVal = AvailableLoads.lookup(MemInst.getPointerOperand()); + LoadValue InVal = AvailableLoads.lookup(MemInst.getPtr()); if (InVal.Data != nullptr && InVal.Generation == CurrentGeneration && InVal.MatchingId == MemInst.getMatchingId()) { Value *Op = getOrCreateResult(InVal.Data, Inst->getType()); @@ -584,7 +583,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { // Otherwise, remember that we have this instruction. AvailableLoads.insert( - MemInst.getPointerOperand(), + MemInst.getPtr(), LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId())); LastStore = nullptr; continue; @@ -660,7 +659,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { // to non-volatile loads, so we don't have to check for volatility of // the store. AvailableLoads.insert( - MemInst.getPointerOperand(), + MemInst.getPtr(), LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId())); // Remember that this was the last normal store we saw for DSE. -- 2.34.1