summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/UnrollLoop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils/UnrollLoop.cpp')
-rw-r--r--lib/Transforms/Utils/UnrollLoop.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Transforms/Utils/UnrollLoop.cpp b/lib/Transforms/Utils/UnrollLoop.cpp
index caef7ec..4d838b5 100644
--- a/lib/Transforms/Utils/UnrollLoop.cpp
+++ b/lib/Transforms/Utils/UnrollLoop.cpp
@@ -25,6 +25,7 @@
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
@@ -62,7 +63,7 @@ static BasicBlock *FoldBlockIntoPredecessor(BasicBlock *BB, LoopInfo* LI) {
if (OnlyPred->getTerminator()->getNumSuccessors() != 1)
return 0;
- DOUT << "Merging: " << *BB << "into: " << *OnlyPred;
+ DEBUG(errs() << "Merging: " << *BB << "into: " << *OnlyPred);
// Resolve any PHI nodes at the start of the block. They are all
// guaranteed to have exactly one entry if they exist, unless there are
@@ -113,7 +114,8 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM)
if (!BI || BI->isUnconditional()) {
// The loop-rotate pass can be helpful to avoid this in many cases.
- DOUT << " Can't unroll; loop not terminated by a conditional branch.\n";
+ DEBUG(errs() <<
+ " Can't unroll; loop not terminated by a conditional branch.\n");
return false;
}
@@ -125,9 +127,9 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM)
TripMultiple = L->getSmallConstantTripMultiple();
if (TripCount != 0)
- DOUT << " Trip Count = " << TripCount << "\n";
+ DEBUG(errs() << " Trip Count = " << TripCount << "\n");
if (TripMultiple != 1)
- DOUT << " Trip Multiple = " << TripMultiple << "\n";
+ DEBUG(errs() << " Trip Multiple = " << TripMultiple << "\n");
// Effectively "DCE" unrolled iterations that are beyond the tripcount
// and will never be executed.
@@ -153,17 +155,17 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM)
}
if (CompletelyUnroll) {
- DOUT << "COMPLETELY UNROLLING loop %" << Header->getName()
- << " with trip count " << TripCount << "!\n";
+ DEBUG(errs() << "COMPLETELY UNROLLING loop %" << Header->getName()
+ << " with trip count " << TripCount << "!\n");
} else {
- DOUT << "UNROLLING loop %" << Header->getName()
- << " by " << Count;
+ DEBUG(errs() << "UNROLLING loop %" << Header->getName()
+ << " by " << Count);
if (TripMultiple == 0 || BreakoutTrip != TripMultiple) {
- DOUT << " with a breakout at trip " << BreakoutTrip;
+ DEBUG(errs() << " with a breakout at trip " << BreakoutTrip);
} else if (TripMultiple != 1) {
- DOUT << " with " << TripMultiple << " trips per branch";
+ DEBUG(errs() << " with " << TripMultiple << " trips per branch");
}
- DOUT << "!\n";
+ DEBUG(errs() << "!\n");
}
std::vector<BasicBlock*> LoopBlocks = L->getBlocks();
@@ -349,7 +351,8 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM)
if (isInstructionTriviallyDead(Inst))
(*BB)->getInstList().erase(Inst);
- else if (Constant *C = ConstantFoldInstruction(Inst)) {
+ else if (Constant *C = ConstantFoldInstruction(Inst,
+ Header->getContext())) {
Inst->replaceAllUsesWith(C);
(*BB)->getInstList().erase(Inst);
}
OpenPOWER on IntegriCloud