mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-05 14:34:55 +00:00
improve debug output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22638 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1c73c7be9d
commit
be3e5212e2
@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#define DEBUG_TYPE "loop-reduce"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
@ -553,6 +554,8 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
|
|||||||
BasicBlock *LatchBlock =
|
BasicBlock *LatchBlock =
|
||||||
SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader);
|
SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader);
|
||||||
|
|
||||||
|
DEBUG(std::cerr << "INSERTING IVs of STRIDE " << *Stride << ":\n");
|
||||||
|
|
||||||
// FIXME: This loop needs increasing levels of intelligence.
|
// FIXME: This loop needs increasing levels of intelligence.
|
||||||
// STAGE 0: just emit everything as its own base.
|
// STAGE 0: just emit everything as its own base.
|
||||||
// STAGE 1: factor out common vars from bases, and try and push resulting
|
// STAGE 1: factor out common vars from bases, and try and push resulting
|
||||||
@ -565,7 +568,9 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
|
|||||||
std::sort(UsersToProcess.begin(), UsersToProcess.end());
|
std::sort(UsersToProcess.begin(), UsersToProcess.end());
|
||||||
while (!UsersToProcess.empty()) {
|
while (!UsersToProcess.empty()) {
|
||||||
SCEVHandle Base = UsersToProcess.front().first;
|
SCEVHandle Base = UsersToProcess.front().first;
|
||||||
|
|
||||||
|
DEBUG(std::cerr << " INSERTING PHI with BASE = " << *Base << ":\n");
|
||||||
|
|
||||||
// Create a new Phi for this base, and stick it in the loop header.
|
// Create a new Phi for this base, and stick it in the loop header.
|
||||||
const Type *ReplacedTy = Base->getType();
|
const Type *ReplacedTy = Base->getType();
|
||||||
PHINode *NewPHI = new PHINode(ReplacedTy, "iv.", PhiInsertBefore);
|
PHINode *NewPHI = new PHINode(ReplacedTy, "iv.", PhiInsertBefore);
|
||||||
@ -595,14 +600,14 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
|
|||||||
Rewriter.clear();
|
Rewriter.clear();
|
||||||
SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(NewPHI),
|
SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(NewPHI),
|
||||||
User.Imm);
|
User.Imm);
|
||||||
Value *Replaced = UsersToProcess.front().second.OperandValToReplace;
|
Value *Replaced = User.OperandValToReplace;
|
||||||
Value *newVal = Rewriter.expandCodeFor(NewValSCEV, User.Inst,
|
Value *newVal = Rewriter.expandCodeFor(NewValSCEV, User.Inst,
|
||||||
Replaced->getType());
|
Replaced->getType());
|
||||||
|
|
||||||
// Replace the use of the operand Value with the new Phi we just created.
|
// Replace the use of the operand Value with the new Phi we just created.
|
||||||
DEBUG(std::cerr << "REPLACING: " << *Replaced << "IN: " <<
|
|
||||||
*User.Inst << "WITH: "<< *newVal << '\n');
|
|
||||||
User.Inst->replaceUsesOfWith(Replaced, newVal);
|
User.Inst->replaceUsesOfWith(Replaced, newVal);
|
||||||
|
DEBUG(std::cerr << " CHANGED: IMM =" << *User.Imm << " Inst = "
|
||||||
|
<< *User.Inst);
|
||||||
|
|
||||||
// Mark old value we replaced as possibly dead, so that it is elminated
|
// Mark old value we replaced as possibly dead, so that it is elminated
|
||||||
// if we just replaced the last use of that value.
|
// if we just replaced the last use of that value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user