Deleted Added
full compact
GVN.cpp (207618) GVN.cpp (207631)
1//===- GVN.cpp - Eliminate redundant values and loads ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 1570 unchanged lines hidden (view full) ---

1579 // available.
1580 DenseMap<BasicBlock*, Value*> PredLoads;
1581 DenseMap<BasicBlock*, char> FullyAvailableBlocks;
1582 for (unsigned i = 0, e = ValuesPerBlock.size(); i != e; ++i)
1583 FullyAvailableBlocks[ValuesPerBlock[i].BB] = true;
1584 for (unsigned i = 0, e = UnavailableBlocks.size(); i != e; ++i)
1585 FullyAvailableBlocks[UnavailableBlocks[i]] = false;
1586
1//===- GVN.cpp - Eliminate redundant values and loads ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 1570 unchanged lines hidden (view full) ---

1579 // available.
1580 DenseMap<BasicBlock*, Value*> PredLoads;
1581 DenseMap<BasicBlock*, char> FullyAvailableBlocks;
1582 for (unsigned i = 0, e = ValuesPerBlock.size(); i != e; ++i)
1583 FullyAvailableBlocks[ValuesPerBlock[i].BB] = true;
1584 for (unsigned i = 0, e = UnavailableBlocks.size(); i != e; ++i)
1585 FullyAvailableBlocks[UnavailableBlocks[i]] = false;
1586
1587 bool NeedToSplitEdges = false;
1587 SmallVector<std::pair<TerminatorInst*, unsigned>, 4> NeedToSplit;
1588 for (pred_iterator PI = pred_begin(LoadBB), E = pred_end(LoadBB);
1589 PI != E; ++PI) {
1590 BasicBlock *Pred = *PI;
1591 if (IsValueFullyAvailableInBlock(Pred, FullyAvailableBlocks)) {
1592 continue;
1593 }
1594 PredLoads[Pred] = 0;
1595
1596 if (Pred->getTerminator()->getNumSuccessors() != 1) {
1597 if (isa<IndirectBrInst>(Pred->getTerminator())) {
1598 DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF INDBR CRITICAL EDGE '"
1599 << Pred->getName() << "': " << *LI << '\n');
1600 return false;
1601 }
1602 unsigned SuccNum = GetSuccessorNumber(Pred, LoadBB);
1588 for (pred_iterator PI = pred_begin(LoadBB), E = pred_end(LoadBB);
1589 PI != E; ++PI) {
1590 BasicBlock *Pred = *PI;
1591 if (IsValueFullyAvailableInBlock(Pred, FullyAvailableBlocks)) {
1592 continue;
1593 }
1594 PredLoads[Pred] = 0;
1595
1596 if (Pred->getTerminator()->getNumSuccessors() != 1) {
1597 if (isa<IndirectBrInst>(Pred->getTerminator())) {
1598 DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF INDBR CRITICAL EDGE '"
1599 << Pred->getName() << "': " << *LI << '\n');
1600 return false;
1601 }
1602 unsigned SuccNum = GetSuccessorNumber(Pred, LoadBB);
1603 toSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum));
1604 NeedToSplitEdges = true;
1603 NeedToSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum));
1605 }
1606 }
1604 }
1605 }
1607 if (NeedToSplitEdges)
1606 if (!NeedToSplit.empty()) {
1607 toSplit.append(NeedToSplit.size(), NeedToSplit.front());
1608 return false;
1608 return false;
1609 }
1609
1610 // Decide whether PRE is profitable for this load.
1611 unsigned NumUnavailablePreds = PredLoads.size();
1612 assert(NumUnavailablePreds != 0 &&
1613 "Fully available value should be eliminated above!");
1614 if (!EnableFullLoadPRE) {
1615 // If this load is unavailable in multiple predecessors, reject it.
1616 // FIXME: If we could restructure the CFG, we could make a common pred with

--- 694 unchanged lines hidden ---
1610
1611 // Decide whether PRE is profitable for this load.
1612 unsigned NumUnavailablePreds = PredLoads.size();
1613 assert(NumUnavailablePreds != 0 &&
1614 "Fully available value should be eliminated above!");
1615 if (!EnableFullLoadPRE) {
1616 // If this load is unavailable in multiple predecessors, reject it.
1617 // FIXME: If we could restructure the CFG, we could make a common pred with

--- 694 unchanged lines hidden ---