[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Changes in directory llvm/lib/Transforms/Scalar: LoopUnswitch.cpp updated: 1.13 -> 1.14 --- Log message: Fix a case where UnswitchTrivialCondition broke critical edges with phi's in the successors --- Diffs of the changes: (+24 -1) LoopUnswitch.cpp | 25 - 1 files changed, 24 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.13 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.14 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.13Thu Feb 9 20:30:37 2006 +++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Feb 10 13:08:15 2006 @@ -34,6 +34,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" #include "llvm/Support/CommandLine.h" @@ -255,6 +256,8 @@ // loop. for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E; ++I) { +for (BasicBlock::iterator BBI = (*I)->begin(), E = (*I)->end(); + BBI != E; ++BBI) TerminatorInst *TI = (*I)->getTerminator(); // FIXME: Handle invariant select instructions. @@ -415,7 +418,27 @@ // Split this block now, so that the loop maintains its exit block. assert(!L->contains(ExitBlock) && "Exit block is in the loop?"); - BasicBlock *NewExit = SplitBlock(ExitBlock, true); + BasicBlock *NewExit; + if (BasicBlock *SinglePred = ExitBlock->getSinglePredecessor()) { +assert(SinglePred == L->getLoopLatch() && "Unexpected case"); +NewExit = SplitBlock(ExitBlock, true); + } else { +// Otherwise, this is a critical edge. Split block would split the wrong +// edge here, so we use SplitCriticalEdge, which allows us to specify the +// edge to split, not just the block. +TerminatorInst *LatchTerm = L->getLoopLatch()->getTerminator(); +unsigned SuccNum = 0; +for (unsigned i = 0, e = LatchTerm->getNumSuccessors(); ; ++i) { + assert(i != e && "Didn't find edge?"); + if (LatchTerm->getSuccessor(i) == ExitBlock) { +SuccNum = i; +break; + } +} +SplitCriticalEdge(LatchTerm, SuccNum, this); +NewExit = LatchTerm->getSuccessor(SuccNum); +assert(NewExit != ExitBlock && "Edge not split!"); + } // Okay, now we have a position to branch from and a position to branch to, // insert the new conditional branch. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
Changes in directory llvm/include/llvm/Transforms/Utils: BasicBlockUtils.h updated: 1.10 -> 1.11 --- Log message: Remove a level of indirection. --- Diffs of the changes: (+8 -9) BasicBlockUtils.h | 17 - 1 files changed, 8 insertions(+), 9 deletions(-) Index: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h diff -u llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.10 llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.11 --- llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.10 Wed Aug 17 01:34:37 2005 +++ llvm/include/llvm/Transforms/Utils/BasicBlockUtils.hFri Feb 10 15:32:11 2006 @@ -76,20 +76,19 @@ /// This updates all of the same analyses as the other SplitCriticalEdge /// function. inline bool SplitCriticalEdge(BasicBlock *Succ, pred_iterator PI, Pass *P = 0) { - BasicBlock *Pred = *PI; bool MadeChange = false; - for (succ_iterator SI = succ_begin(Pred), E = succ_end(Pred); SI != E; ++SI) -if (*SI == Succ) - MadeChange |= SplitCriticalEdge(Pred, SI, P); + TerminatorInst *TI = (*PI)->getTerminator(); + for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) +if (TI->getSuccessor(i) == Succ) + MadeChange |= SplitCriticalEdge(TI, i, P); return MadeChange; } inline bool SplitCriticalEdge(BasicBlock *Src, BasicBlock *Dst, Pass *P = 0) { - for (succ_iterator SI = succ_begin(Src); ; ++SI) { -assert(SI != succ_end(Src) && "Edge doesn't exist"); -if (*SI == Dst) - return SplitCriticalEdge(Src, SI, P); - } + TerminatorInst *TI = Src->getTerminator(); + for (unsigned i = 0, e = TI->getNumSuccessors(); ; ++i) +if (TI->getSuccessor(i) == Dst) + return SplitCriticalEdge(TI, i, P); } } // End llvm namespace ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/X86: X86ISelDAGToDAG.cpp updated: 1.46 -> 1.47 --- Log message: Added X86 isel debugging stuff. --- Diffs of the changes: (+63 -0) X86ISelDAGToDAG.cpp | 63 1 files changed, 63 insertions(+) Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.46 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.47 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.46Thu Feb 9 16:12:53 2006 +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Feb 10 16:24:32 2006 @@ -12,6 +12,7 @@ // //===--===// +#define DEBUG_TYPE "isel" #include "X86.h" #include "X86InstrBuilder.h" #include "X86RegisterInfo.h" @@ -143,6 +144,8 @@ inline SDOperand getI32Imm(unsigned Imm) { return CurDAG->getTargetConstant(Imm, MVT::i32); } + +std::string Indent; }; } @@ -153,7 +156,14 @@ MachineFunction::iterator FirstMBB = BB; // Codegen the basic block. +#ifndef NDEBUG + DEBUG(std::cerr << "= Instruction selection begins:\n"); + Indent = ""; +#endif DAG.setRoot(SelectRoot(DAG.getRoot())); +#ifndef NDEBUG + DEBUG(std::cerr << "= Instruction selection ends:\n"); +#endif CodeGenMap.clear(); DAG.RemoveDeadNodes(); @@ -451,14 +461,37 @@ unsigned Opc, MOpc; unsigned Opcode = Node->getOpcode(); +#ifndef NDEBUG + std::string IndentSave = Indent; + DEBUG(std::cerr << Indent); + DEBUG(std::cerr << "Selecting: "); + DEBUG(Node->dump(CurDAG)); + DEBUG(std::cerr << "\n"); + Indent += " "; +#endif + if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER) { Result = N; +#ifndef NDEBUG +DEBUG(std::cerr << Indent); +DEBUG(std::cerr << "== "); +DEBUG(Node->dump(CurDAG)); +DEBUG(std::cerr << "\n"); +Indent = IndentSave; +#endif return; // Already selected. } std::map::iterator CGMI = CodeGenMap.find(N); if (CGMI != CodeGenMap.end()) { Result = CGMI->second; +#ifndef NDEBUG +DEBUG(std::cerr << Indent); +DEBUG(std::cerr << "== "); +DEBUG(Result.Val->dump(CurDAG)); +DEBUG(std::cerr << "\n"); +Indent = IndentSave; +#endif return; } @@ -539,6 +572,13 @@ AddHandleReplacement(N1.Val, 1, Result.Val, 1); } +#ifndef NDEBUG + DEBUG(std::cerr << Indent); + DEBUG(std::cerr << "== "); + DEBUG(Result.Val->dump(CurDAG)); + DEBUG(std::cerr << "\n"); + Indent = IndentSave; +#endif return; } @@ -639,6 +679,14 @@ CodeGenMap[N1.getValue(1)] = Result.getValue(1); AddHandleReplacement(N1.Val, 1, Result.Val, 1); } + +#ifndef NDEBUG + DEBUG(std::cerr << Indent); + DEBUG(std::cerr << "== "); + DEBUG(Result.Val->dump(CurDAG)); + DEBUG(std::cerr << "\n"); + Indent = IndentSave; +#endif return; } @@ -670,11 +718,26 @@ else Result = CodeGenMap[N] = SDOperand(CurDAG->getTargetNode(Opc, VT, Result), 0); + +#ifndef NDEBUG + DEBUG(std::cerr << Indent); + DEBUG(std::cerr << "== "); + DEBUG(Result.Val->dump(CurDAG)); + DEBUG(std::cerr << "\n"); + Indent = IndentSave; +#endif return; } } SelectCode(Result, N); +#ifndef NDEBUG + DEBUG(std::cerr << Indent); + DEBUG(std::cerr << "=> "); + DEBUG(Result.Val->dump(CurDAG)); + DEBUG(std::cerr << "\n"); + Indent = IndentSave; +#endif } /// createX86ISelDag - This pass converts a legalized DAG into a ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/X86: X86ISelDAGToDAG.cpp updated: 1.47 -> 1.48 --- Log message: Nicer code. :-) --- Diffs of the changes: (+18 -17) X86ISelDAGToDAG.cpp | 35 ++- 1 files changed, 18 insertions(+), 17 deletions(-) Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.47 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.48 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.47Fri Feb 10 16:24:32 2006 +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Feb 10 16:46:26 2006 @@ -145,7 +145,9 @@ return CurDAG->getTargetConstant(Imm, MVT::i32); } -std::string Indent; +#ifndef NDEBUG +unsigned Indent; +#endif }; } @@ -158,7 +160,7 @@ // Codegen the basic block. #ifndef NDEBUG DEBUG(std::cerr << "= Instruction selection begins:\n"); - Indent = ""; + Indent = 0; #endif DAG.setRoot(SelectRoot(DAG.getRoot())); #ifndef NDEBUG @@ -462,22 +464,21 @@ unsigned Opcode = Node->getOpcode(); #ifndef NDEBUG - std::string IndentSave = Indent; - DEBUG(std::cerr << Indent); + DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "Selecting: "); DEBUG(Node->dump(CurDAG)); DEBUG(std::cerr << "\n"); - Indent += " "; + Indent += 2; #endif if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER) { Result = N; #ifndef NDEBUG -DEBUG(std::cerr << Indent); +DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "== "); DEBUG(Node->dump(CurDAG)); DEBUG(std::cerr << "\n"); -Indent = IndentSave; +Indent -= 2; #endif return; // Already selected. } @@ -486,11 +487,11 @@ if (CGMI != CodeGenMap.end()) { Result = CGMI->second; #ifndef NDEBUG -DEBUG(std::cerr << Indent); +DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "== "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); -Indent = IndentSave; +Indent -= 2; #endif return; } @@ -573,11 +574,11 @@ } #ifndef NDEBUG - DEBUG(std::cerr << Indent); + DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "== "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); - Indent = IndentSave; + Indent -= 2; #endif return; } @@ -681,11 +682,11 @@ } #ifndef NDEBUG - DEBUG(std::cerr << Indent); + DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "== "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); - Indent = IndentSave; + Indent -= 2; #endif return; } @@ -720,11 +721,11 @@ SDOperand(CurDAG->getTargetNode(Opc, VT, Result), 0); #ifndef NDEBUG - DEBUG(std::cerr << Indent); + DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "== "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); - Indent = IndentSave; + Indent -= 2; #endif return; } @@ -732,11 +733,11 @@ SelectCode(Result, N); #ifndef NDEBUG - DEBUG(std::cerr << Indent); + DEBUG(std::cerr << std::string(Indent, ' ')); DEBUG(std::cerr << "=> "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); - Indent = IndentSave; + Indent -= 2; #endif } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Changes in directory llvm/lib/Transforms/Scalar: LoopUnswitch.cpp updated: 1.14 -> 1.15 --- Log message: Reform the unswitching code in terms of edge splitting, not block splitting. --- Diffs of the changes: (+67 -49) LoopUnswitch.cpp | 116 +++ 1 files changed, 67 insertions(+), 49 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.14 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.15 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.14Fri Feb 10 13:08:15 2006 +++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Feb 10 17:16:39 2006 @@ -68,7 +68,7 @@ private: unsigned getLoopUnswitchCost(Loop *L, Value *LIC); void VersionLoop(Value *LIC, Loop *L, Loop *&Out1, Loop *&Out2); -BasicBlock *SplitBlock(BasicBlock *BB, bool SplitAtTop); +BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To); void RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, bool Val); void UnswitchTrivialCondition(Loop *L, Value *Cond, bool EntersLoopOnCond, BasicBlock *ExitBlock); @@ -256,8 +256,6 @@ // loop. for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E; ++I) { -for (BasicBlock::iterator BBI = (*I)->begin(), E = (*I)->end(); - BBI != E; ++BBI) TerminatorInst *TI = (*I)->getTerminator(); // FIXME: Handle invariant select instructions. @@ -329,31 +327,49 @@ return Changed; } -/// SplitBlock - Split the specified basic block into two pieces. If SplitAtTop -/// is false, this splits the block so the second half only has an unconditional -/// branch. If SplitAtTop is true, it makes it so the first half of the block -/// only has an unconditional branch in it. -/// -/// This method updates the LoopInfo for this function to correctly reflect the -/// CFG changes made. -/// -/// This routine returns the new basic block that was inserted, which is always -/// the later part of the block. -BasicBlock *LoopUnswitch::SplitBlock(BasicBlock *BB, bool SplitAtTop) { +BasicBlock *LoopUnswitch::SplitEdge(BasicBlock *BB, BasicBlock *Succ) { + TerminatorInst *LatchTerm = BB->getTerminator(); + unsigned SuccNum = 0; + for (unsigned i = 0, e = LatchTerm->getNumSuccessors(); ; ++i) { +assert(i != e && "Didn't find edge?"); +if (LatchTerm->getSuccessor(i) == Succ) { + SuccNum = i; + break; +} + } + + // If this is a critical edge, let SplitCriticalEdge do it. + if (SplitCriticalEdge(BB->getTerminator(), SuccNum, this)) +return LatchTerm->getSuccessor(SuccNum); + + // If the edge isn't critical, then BB has a single successor or Succ has a + // single pred. Split the block. + BasicBlock *BlockToSplit; BasicBlock::iterator SplitPoint; - if (!SplitAtTop) + if (BasicBlock *SP = Succ->getSinglePredecessor()) { +// If the successor only has a single pred, split the top of the successor +// block. +assert(SP == BB && "CFG broken"); +BlockToSplit = Succ; +SplitPoint = Succ->begin(); + } else { +// Otherwise, if BB has a single successor, split it at the bottom of the +// block. +assert(BB->getTerminator()->getNumSuccessors() == 1 && + "Should have a single succ!"); +BlockToSplit = BB; SplitPoint = BB->getTerminator(); - else { -SplitPoint = BB->begin(); -while (isa(SplitPoint)) ++SplitPoint; } - - BasicBlock *New = BB->splitBasicBlock(SplitPoint, BB->getName()+".tail"); + + BasicBlock *New = +BlockToSplit->splitBasicBlock(SplitPoint, + BlockToSplit->getName()+".tail"); // New now lives in whichever loop that BB used to. - if (Loop *L = LI->getLoopFor(BB)) + if (Loop *L = LI->getLoopFor(BlockToSplit)) L->addBasicBlockToLoop(New, *LI); return New; } + // RemapInstruction - Convert the instruction operands from referencing the @@ -406,40 +422,21 @@ << " blocks] in Function " << L->getHeader()->getParent()->getName() << " on cond:" << *Cond << "\n"); - // First step, split the preahder, so that we know that there is a safe place + // First step, split the preheader, so that we know that there is a safe place // to insert the conditional branch. We will change 'OrigPH' to have a // conditional branch on Cond. BasicBlock *OrigPH = L->getLoopPreheader(); - BasicBlock *NewPH = SplitBlock(OrigPH, false); + BasicBlock *NewPH = SplitEdge(OrigPH, L->getHeader()); // Now that we have a place to insert the conditional branch, create a place // to branch to: this is the exit block out of the loop that we should // short-circuit to. - // Split this block now, so that the loop maintains its exit block. + // Split this edge now, so that the loop maintains its exit block. assert(!L->contains(ExitBlock) && "Exit block is in the loop?"); - BasicBlock *NewExit; - if (BasicBlock *S
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Changes in directory llvm/lib/Transforms/Scalar: LoopUnswitch.cpp updated: 1.15 -> 1.16 --- Log message: Update PHI nodes in successors of exit blocks. --- Diffs of the changes: (+34 -5) LoopUnswitch.cpp | 39 ++- 1 files changed, 34 insertions(+), 5 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.15 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.16 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.15Fri Feb 10 17:16:39 2006 +++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Feb 10 17:26:14 2006 @@ -256,6 +256,16 @@ // loop. for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E; ++I) { +for (BasicBlock::iterator BBI = (*I)->begin(), E = (*I)->end(); + BBI != E; ++BBI) + if (SelectInst *SI = dyn_cast(BBI)) { +Value *LoopCond = FindLIVLoopCondition(SI->getCondition(), L, Changed); +if (LoopCond == 0) continue; + +//if (UnswitchIfProfitable(LoopCond, +std::cerr << "LOOP INVARIANT SELECT: " << *SI; + } + TerminatorInst *TI = (*I)->getTerminator(); // FIXME: Handle invariant select instructions. @@ -523,13 +533,32 @@ // Now we create the new Loop object for the versioned loop. Loop *NewLoop = CloneLoop(L, L->getParentLoop(), ValueMap, LI); - if (Loop *Parent = L->getParentLoop()) { + Loop *ParentLoop = L->getParentLoop(); + if (ParentLoop) { // Make sure to add the cloned preheader and exit blocks to the parent loop // as well. -Parent->addBasicBlockToLoop(NewBlocks[0], *LI); -for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) - Parent->addBasicBlockToLoop(cast(ValueMap[ExitBlocks[i]]), - *LI); +ParentLoop->addBasicBlockToLoop(NewBlocks[0], *LI); + } + + for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { +BasicBlock *NewExit = cast(ValueMap[ExitBlocks[i]]); +if (ParentLoop) + ParentLoop->addBasicBlockToLoop(cast(NewExit), *LI); + +assert(NewExit->getTerminator()->getNumSuccessors() == 1 && + "Exit block should have been split to have one successor!"); +BasicBlock *ExitSucc = NewExit->getTerminator()->getSuccessor(0); + +// If the successor of the exit block had PHI nodes, add an entry for +// NewExit. +PHINode *PN; +for (BasicBlock::iterator I = ExitSucc->begin(); + (PN = dyn_cast(I)); ++I) { + Value *V = PN->getIncomingValueForBlock(ExitBlocks[i]); + std::map::iterator It = ValueMap.find(V); + if (It != ValueMap.end()) V = It->second; + PN->addIncoming(V, NewExit); +} } // Rewrite the code to refer to itself. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Changes in directory llvm/lib/Transforms/Scalar: LoopUnswitch.cpp updated: 1.16 -> 1.17 --- Log message: implement unswitching of loops with switch stmts and selects in them --- Diffs of the changes: (+135 -94) LoopUnswitch.cpp | 229 --- 1 files changed, 135 insertions(+), 94 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.16 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.17 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.16Fri Feb 10 17:26:14 2006 +++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Feb 10 18:43:37 2006 @@ -66,10 +66,13 @@ } private: +bool UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L); unsigned getLoopUnswitchCost(Loop *L, Value *LIC); -void VersionLoop(Value *LIC, Loop *L, Loop *&Out1, Loop *&Out2); +void VersionLoop(Value *LIC, Constant *OnVal, + Loop *L, Loop *&Out1, Loop *&Out2); BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To); -void RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, bool Val); +void RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,Constant *Val, + bool isEqual); void UnswitchTrivialCondition(Loop *L, Value *Cond, bool EntersLoopOnCond, BasicBlock *ExitBlock); }; @@ -256,85 +259,86 @@ // loop. for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E; ++I) { +TerminatorInst *TI = (*I)->getTerminator(); +if (BranchInst *BI = dyn_cast(TI)) { + // If this isn't branching on an invariant condition, we can't unswitch + // it. + if (BI->isConditional()) { +// See if this, or some part of it, is loop invariant. If so, we can +// unswitch on it if we desire. +Value *LoopCond = FindLIVLoopCondition(BI->getCondition(), L, Changed); +if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::True, L)) + return true; + } +} else if (SwitchInst *SI = dyn_cast(TI)) { + Value *LoopCond = FindLIVLoopCondition(SI->getCondition(), L, Changed); + if (LoopCond && SI->getNumCases() > 1) { +// Find a value to unswitch on: +// FIXME: this should chose the most expensive case! +Constant *UnswitchVal = SI->getCaseValue(1); +if (UnswitchIfProfitable(LoopCond, UnswitchVal, L)) + return true; + } +} + +// Scan the instructions to check for unswitchable values. for (BasicBlock::iterator BBI = (*I)->begin(), E = (*I)->end(); BBI != E; ++BBI) if (SelectInst *SI = dyn_cast(BBI)) { Value *LoopCond = FindLIVLoopCondition(SI->getCondition(), L, Changed); -if (LoopCond == 0) continue; - -//if (UnswitchIfProfitable(LoopCond, -std::cerr << "LOOP INVARIANT SELECT: " << *SI; +if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::True, L)) + return true; } - -TerminatorInst *TI = (*I)->getTerminator(); -// FIXME: Handle invariant select instructions. - -if (SwitchInst *SI = dyn_cast(TI)) { - if (!isa(SI) && L->isLoopInvariant(SI->getCondition())) -DEBUG(std::cerr << "TODO: Implement unswitching 'switch' loop %" - << L->getHeader()->getName() << ", cost = " - << L->getBlocks().size() << "\n" << **I); - continue; -} - -BranchInst *BI = dyn_cast(TI); -if (!BI) continue; - -// If this isn't branching on an invariant condition, we can't unswitch it. -if (!BI->isConditional()) - continue; - -// See if this, or some part of it, is loop invariant. If so, we can -// unswitch on it if we desire. -Value *LoopCond = FindLIVLoopCondition(BI->getCondition(), L, Changed); -if (LoopCond == 0) continue; + } -// Check to see if it would be profitable to unswitch this loop. -if (getLoopUnswitchCost(L, LoopCond) > Threshold) { - // FIXME: this should estimate growth by the amount of code shared by the - // resultant unswitched loops. This should have no code growth: - //for () { if (iv) {...} } - // as one copy of the loop will be empty. - // - DEBUG(std::cerr << "NOT unswitching loop %" -<< L->getHeader()->getName() << ", cost too high: " -<< L->getBlocks().size() << "\n"); - continue; -} + return Changed; +} + +/// UnswitchIfProfitable - We have found that we can unswitch L when +/// LoopCond == Val to simplify the loop. If we decide that this is profitable, +/// unswitch the loop, reprocess the pieces, then return true. +bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){ + // Check to see if it would be profitable to unswitch this loop. + if (getLoopUnswitchCost(L, LoopCond) > Threshold) { +/
[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineDebugInfo.h
Changes in directory llvm/include/llvm/CodeGen: MachineDebugInfo.h updated: 1.13 -> 1.14 --- Log message: Reorg for integration with gcc4. Old style debug info will not be passed though to SelIDAG. --- Diffs of the changes: (+169 -59) MachineDebugInfo.h | 228 +++-- 1 files changed, 169 insertions(+), 59 deletions(-) Index: llvm/include/llvm/CodeGen/MachineDebugInfo.h diff -u llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.13 llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.14 --- llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.13 Mon Feb 6 15:54:05 2006 +++ llvm/include/llvm/CodeGen/MachineDebugInfo.hFri Feb 10 19:01:30 2006 @@ -32,6 +32,7 @@ #include "llvm/Support/Dwarf.h" #include "llvm/ADT/UniqueVector.h" +#include "llvm/GlobalValue.h" #include "llvm/Pass.h" #include "llvm/User.h" @@ -42,6 +43,7 @@ //===--===// // Forward declarations. +class Constant; class DebugInfoDesc; class GlobalVariable; class Module; @@ -57,12 +59,13 @@ // DebugInfoDesc type identifying tags. // FIXME - Change over with gcc4. + DI_TAG_anchor = 0, #if 1 DI_TAG_compile_unit = DW_TAG_compile_unit, DI_TAG_global_variable = DW_TAG_variable, DI_TAG_subprogram = DW_TAG_subprogram #else - DI_TAG_compile_unit = 1, + DI_TAG_compile_unit, DI_TAG_global_variable, DI_TAG_subprogram #endif @@ -117,6 +120,10 @@ /// Return NULL if not a recognized Tag. static DebugInfoDesc *DescFactory(unsigned Tag); + /// getLinkage - get linkage appropriate for this type of descriptor. + /// + virtual GlobalValue::LinkageTypes getLinkage() const; + //======// // Subclasses should supply the following static methods. @@ -128,11 +135,15 @@ /// ApplyToFields - Target the vistor to the fields of the descriptor. /// - virtual void ApplyToFields(DIVisitor *Visitor) = 0; + virtual void ApplyToFields(DIVisitor *Visitor); - /// TypeString - Return a string used to compose globalnames and labels. + /// getDescString - Return a string used to compose global names and labels. /// - virtual const char *TypeString() const = 0; + virtual const char *getDescString() const = 0; + + /// getTypeString - Return a string used to label this descriptor's type. + /// + virtual const char *getTypeString() const = 0; #ifndef NDEBUG virtual void dump() = 0; @@ -141,27 +152,90 @@ //===--===// +/// AnchorDesc - Descriptors of this class act as markers for identifying +/// descriptors of certain groups. +class AnchorDesc : public DebugInfoDesc { +private: + std::string Name; // Anchor type string. + +public: + AnchorDesc() + : DebugInfoDesc(DI_TAG_anchor) + , Name("") + {} + AnchorDesc(const std::string &N) + : DebugInfoDesc(DI_TAG_anchor) + , Name(N) + {} + + // Accessors + const std::string &getName() const { return Name; } + + // Implement isa/cast/dyncast. + static bool classof(const AnchorDesc *) { return true; } + static bool classof(const DebugInfoDesc *D) { +return D->getTag() == DI_TAG_anchor; + } + + /// getLinkage - get linkage appropriate for this type of descriptor. + /// + virtual GlobalValue::LinkageTypes getLinkage() const; + + /// ApplyToFields - Target the visitor to the fields of the AnchorDesc. + /// + virtual void ApplyToFields(DIVisitor *Visitor); + + /// getDescString - Return a string used to compose global names and labels. + /// + virtual const char *getDescString() const; + + /// getTypeString - Return a string used to label this descriptor's type. + /// + virtual const char *getTypeString() const; + +#ifndef NDEBUG + virtual void dump(); +#endif +}; + +//===--===// +/// AnchoredDesc - This class manages anchors for a variety of top level +/// descriptors. +class AnchoredDesc : public DebugInfoDesc { +private: + AnchorDesc *Anchor; // Anchor for all descriptors of the +// same type. + +protected: + + AnchoredDesc(unsigned T); + +public: + // Accessors. + AnchorDesc *getAnchor() const { return Anchor; } + void setAnchor(AnchorDesc *A) { Anchor = A; } + + //======// + // Subclasses should supply the following virtual methods. + + /// ApplyToFields - Target the visitor to the fields of the AnchoredDesc. + /// + virtual void ApplyToFields(DIVisitor *Visitor); +}; + +//===--===// /// CompileUnitDesc - This class packages debug information associated with a /// source/header file. -class CompileUnitDesc : public DebugInfoDesc { +class CompileU
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.150 -> 1.151 --- Log message: Reorg for integration with gcc4. Old style debug info will not be passed though to SelIDAG. --- Diffs of the changes: (+21 -24) SelectionDAGISel.cpp | 45 + 1 files changed, 21 insertions(+), 24 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.150 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.151 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.150Sat Feb 4 00:49:00 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Feb 10 19:01:30 2006 @@ -941,33 +941,30 @@ if (TLI.getTargetMachine().getIntrinsicLowering().EmitDebugFunctions()) return "llvm_debugger_stop"; -std::string fname = ""; -std::vector Ops; +MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo(); +if (DebugInfo && DebugInfo->Verify(I.getOperand(4))) { + std::vector Ops; -// Input Chain -Ops.push_back(getRoot()); - -// line number -Ops.push_back(getValue(I.getOperand(2))); - -// column -Ops.push_back(getValue(I.getOperand(3))); - -// filename/working dir -// Pull the filename out of the the compilation unit. -const GlobalVariable *cunit = dyn_cast(I.getOperand(4)); -if (cunit && cunit->hasInitializer()) { - if (ConstantStruct *CS = -dyn_cast(cunit->getInitializer())) { -if (CS->getNumOperands() > 0) { - Ops.push_back(DAG.getString(getStringValue(CS->getOperand(3; - Ops.push_back(DAG.getString(getStringValue(CS->getOperand(4; -} - } + // Input Chain + Ops.push_back(getRoot()); + + // line number + Ops.push_back(getValue(I.getOperand(2))); + + // column + Ops.push_back(getValue(I.getOperand(3))); + + DebugInfoDesc *DD = DebugInfo->Deserialize(I.getOperand(4)); + assert(DD && "Not a debug information descriptor"); + CompileUnitDesc *CompileUnit = dyn_cast(DD); + assert(CompileUnit && "Not a compile unit"); + Ops.push_back(DAG.getString(CompileUnit->getFileName())); + Ops.push_back(DAG.getString(CompileUnit->getDirectory())); + + if (Ops.size() == 5) // Found filename/workingdir. +DAG.setRoot(DAG.getNode(ISD::LOCATION, MVT::Other, Ops)); } -if (Ops.size() == 5) // Found filename/workingdir. - DAG.setRoot(DAG.getNode(ISD::LOCATION, MVT::Other, Ops)); setValue(&I, DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType(; return 0; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/MachineDebugInfo.cpp
Changes in directory llvm/lib/CodeGen: MachineDebugInfo.cpp updated: 1.12 -> 1.13 --- Log message: Reorg for integration with gcc4. Old style debug info will not be passed though to SelIDAG. --- Diffs of the changes: (+246 -110) MachineDebugInfo.cpp | 356 +++ 1 files changed, 246 insertions(+), 110 deletions(-) Index: llvm/lib/CodeGen/MachineDebugInfo.cpp diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.12 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.13 --- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.12 Mon Feb 6 15:54:05 2006 +++ llvm/lib/CodeGen/MachineDebugInfo.cpp Fri Feb 10 19:01:30 2006 @@ -49,10 +49,14 @@ static std::vector getGlobalVariablesUsing(Module &M, const std::string &RootName) { std::vector Result; // GlobalVariables matching criteria. + + std::vector FieldTypes; + FieldTypes.push_back(Type::UIntTy); + FieldTypes.push_back(PointerType::get(Type::SByteTy)); // Get the GlobalVariable root. GlobalVariable *UseRoot = M.getGlobalVariable(RootName, - StructType::get(std::vector())); +StructType::get(FieldTypes)); // If present and linkonce then scan for users. if (UseRoot && UseRoot->hasLinkOnceLinkage()) { @@ -168,28 +172,6 @@ // Check constant. return dyn_cast(CI->getOperand(i)); } - -//===--===// - -/// TagFromGlobal - Returns the Tag number from a debug info descriptor -/// GlobalVariable. -unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) { - ConstantUInt *C = getUIntOperand(GV, 0); - return C ? (unsigned)C->getValue() : (unsigned)DIInvalid; -} - -/// DescFactory - Create an instance of debug info descriptor based on Tag. -/// Return NULL if not a recognized Tag. -DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) { - switch (Tag) { - case DI_TAG_compile_unit:return new CompileUnitDesc(); - case DI_TAG_global_variable: return new GlobalVariableDesc(); - case DI_TAG_subprogram: return new SubprogramDesc(); - default: break; - } - return NULL; -} - //===--===// /// ApplyToFields - Target the visitor to each field of the debug information @@ -206,7 +188,7 @@ unsigned Count; // Running count of fields. public: - DICountVisitor() : DIVisitor(), Count(1) {} + DICountVisitor() : DIVisitor(), Count(0) {} // Accessors. unsigned getCount() const { return Count; } @@ -234,7 +216,7 @@ DIDeserializeVisitor(DIDeserializer &D, GlobalVariable *GV) : DIVisitor() , DR(D) - , I(1) + , I(0) , CI(cast(GV->getInitializer())) {} @@ -284,7 +266,7 @@ /// Apply - Set the value of each of the fields. /// virtual void Apply(int &Field) { -Elements.push_back(ConstantUInt::get(Type::IntTy, Field)); +Elements.push_back(ConstantSInt::get(Type::IntTy, Field)); } virtual void Apply(unsigned &Field) { Elements.push_back(ConstantUInt::get(Type::UIntTy, Field)); @@ -314,7 +296,11 @@ } virtual void Apply(GlobalVariable *&Field) { const PointerType *EmptyTy = SR.getEmptyStructPtrType(); -Elements.push_back(ConstantExpr::getCast(Field, EmptyTy)); +if (Field) { + Elements.push_back(ConstantExpr::getCast(Field, EmptyTy)); +} else { + Elements.push_back(ConstantPointerNull::get(EmptyTy)); +} } }; @@ -373,7 +359,7 @@ : DIVisitor() , VR(V) , IsValid(true) - , I(1) + , I(0) , CI(cast(GV->getInitializer())) { } @@ -410,36 +396,146 @@ } }; + +//===--===// + +/// TagFromGlobal - Returns the Tag number from a debug info descriptor +/// GlobalVariable. +unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) { + ConstantUInt *C = getUIntOperand(GV, 0); + return C ? (unsigned)C->getValue() : (unsigned)DIInvalid; +} + +/// DescFactory - Create an instance of debug info descriptor based on Tag. +/// Return NULL if not a recognized Tag. +DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) { + switch (Tag) { + case DI_TAG_anchor: return new AnchorDesc(); + case DI_TAG_compile_unit:return new CompileUnitDesc(); + case DI_TAG_global_variable: return new GlobalVariableDesc(); + case DI_TAG_subprogram: return new SubprogramDesc(); + default: break; + } + return NULL; +} + +/// getLinkage - get linkage appropriate for this type of descriptor. +/// +GlobalValue::LinkageTypes DebugInfoDesc::getLinkage() const { + return GlobalValue::InternalLinkage; +} + +/// ApplyToFields - Target the vistor to the fields of the descriptor. +/// +void DebugInfoDesc::ApplyToFields(DIVisitor *Visitor) { + Visitor->Apply(Tag); +} + +//===--===// + +/// getLinkage - get linkage appropriate for this
[llvm-commits] CVS: llvm/lib/Transforms/Utils/LoopSimplify.cpp
Changes in directory llvm/lib/Transforms/Utils: LoopSimplify.cpp updated: 1.62 -> 1.63 --- Log message: remove dead expr --- Diffs of the changes: (+0 -1) LoopSimplify.cpp |1 - 1 files changed, 1 deletion(-) Index: llvm/lib/Transforms/Utils/LoopSimplify.cpp diff -u llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.62 llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.63 --- llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.62 Mon Jan 9 02:03:08 2006 +++ llvm/lib/Transforms/Utils/LoopSimplify.cpp Fri Feb 10 19:43:37 2006 @@ -195,7 +195,6 @@ // incoming values (the loop is canonicalized), we may have simplified the PHI // down to 'X = phi [X, Y]', which should be replaced with 'Y'. PHINode *PN; - DominatorSet &DS = getAnalysis(); for (BasicBlock::iterator I = L->getHeader()->begin(); (PN = dyn_cast(I++)); ) if (Value *V = PN->hasConstantValue()) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/X86: X86ISelDAGToDAG.cpp updated: 1.48 -> 1.49 --- Log message: Prevent certain nodes that have already been selected from being folded into X86 addressing mode. Currently we do not allow any node whose target node produces a chain as well as any node that is at the root of the addressing mode expression tree. --- Diffs of the changes: (+40 -19) X86ISelDAGToDAG.cpp | 59 +++- 1 files changed, 40 insertions(+), 19 deletions(-) Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.48 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.49 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.48Fri Feb 10 16:46:26 2006 +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Feb 10 20:05:36 2006 @@ -107,7 +107,7 @@ private: void Select(SDOperand &Result, SDOperand N); -bool MatchAddress(SDOperand N, X86ISelAddressMode &AM); +bool MatchAddress(SDOperand N, X86ISelAddressMode &AM, bool isRoot = true); bool SelectAddr(SDOperand N, SDOperand &Base, SDOperand &Scale, SDOperand &Index, SDOperand &Disp); bool SelectLEAAddr(SDOperand N, SDOperand &Base, SDOperand &Scale, @@ -252,7 +252,26 @@ /// MatchAddress - Add the specified node to the specified addressing mode, /// returning true if it cannot be done. This just pattern matches for the /// addressing mode -bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM) { +bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM, + bool isRoot) { + bool StopHere = false; + // If N has already been selected, we may or may not want to fold its + // operands into the addressing mode. It will result in code duplication! + // FIXME: Right now we do. That is, as long as the selected target node + // does not produce a chain. This may require a more sophisticated heuristics. + std::map::iterator CGMI= CodeGenMap.find(N.getValue(0)); + if (CGMI != CodeGenMap.end()) { +if (isRoot) + // Stop here if it is a root. It's probably not profitable to go deeper. + StopHere = true; +else { + for (unsigned i = 0, e = CGMI->second.Val->getNumValues(); i != e; ++i) { +if (CGMI->second.Val->getValueType(i) == MVT::Other) + StopHere = true; + } +} + } + switch (N.getOpcode()) { default: break; case ISD::FrameIndex: @@ -287,7 +306,7 @@ return false; case ISD::SHL: -if (AM.IndexReg.Val == 0 && AM.Scale == 1) +if (!StopHere && AM.IndexReg.Val == 0 && AM.Scale == 1) if (ConstantSDNode *CN = dyn_cast(N.Val->getOperand(1))) { unsigned Val = CN->getValue(); if (Val == 1 || Val == 2 || Val == 3) { @@ -313,7 +332,7 @@ case ISD::MUL: // X*[3,5,9] -> X+X*[2,4,8] -if (AM.IndexReg.Val == 0 && AM.BaseType == X86ISelAddressMode::RegBase && +if (!StopHere && AM.IndexReg.Val == 0 && AM.BaseType == X86ISelAddressMode::RegBase && AM.Base.Reg.Val == 0) if (ConstantSDNode *CN = dyn_cast(N.Val->getOperand(1))) if (CN->getValue() == 3 || CN->getValue() == 5 || CN->getValue() == 9) { @@ -341,15 +360,17 @@ break; case ISD::ADD: { -X86ISelAddressMode Backup = AM; -if (!MatchAddress(N.Val->getOperand(0), AM) && -!MatchAddress(N.Val->getOperand(1), AM)) - return false; -AM = Backup; -if (!MatchAddress(N.Val->getOperand(1), AM) && -!MatchAddress(N.Val->getOperand(0), AM)) - return false; -AM = Backup; +if (!StopHere) { + X86ISelAddressMode Backup = AM; + if (!MatchAddress(N.Val->getOperand(0), AM, false) && + !MatchAddress(N.Val->getOperand(1), AM, false)) +return false; + AM = Backup; + if (!MatchAddress(N.Val->getOperand(1), AM, false) && + !MatchAddress(N.Val->getOperand(0), AM, false)) +return false; + AM = Backup; +} break; } } @@ -474,7 +495,7 @@ if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER) { Result = N; #ifndef NDEBUG -DEBUG(std::cerr << std::string(Indent, ' ')); +DEBUG(std::cerr << std::string(Indent-2, ' ')); DEBUG(std::cerr << "== "); DEBUG(Node->dump(CurDAG)); DEBUG(std::cerr << "\n"); @@ -487,7 +508,7 @@ if (CGMI != CodeGenMap.end()) { Result = CGMI->second; #ifndef NDEBUG -DEBUG(std::cerr << std::string(Indent, ' ')); +DEBUG(std::cerr << std::string(Indent-2, ' ')); DEBUG(std::cerr << "== "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); @@ -574,7 +595,7 @@ } #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent, ' ')); + DEBUG(std::cerr << std::string(Indent-2, ' ')); DEBUG(std::cerr << "== "); DEBUG(Result.Val->dump(CurDAG)); DEBUG(std::cerr << "\n"); @@ -682,7 +703,7 @@ } #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent, '
[llvm-commits] CVS: llvm/lib/Transforms/Utils/LoopSimplify.cpp
Changes in directory llvm/lib/Transforms/Utils: LoopSimplify.cpp updated: 1.63 -> 1.64 --- Log message: Make this check stricter. Disallow loop exit blocks from being shared by loops and their subloops. --- Diffs of the changes: (+7 -4) LoopSimplify.cpp | 11 +++ 1 files changed, 7 insertions(+), 4 deletions(-) Index: llvm/lib/Transforms/Utils/LoopSimplify.cpp diff -u llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.63 llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.64 --- llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.63 Fri Feb 10 19:43:37 2006 +++ llvm/lib/Transforms/Utils/LoopSimplify.cpp Fri Feb 10 20:13:17 2006 @@ -109,7 +109,6 @@ return Changed; } - /// ProcessLoop - Walk the loop structure in depth first order, ensuring that /// all loops have preheaders. /// @@ -162,12 +161,15 @@ L->getExitBlocks(ExitBlocks); SetVector ExitBlockSet(ExitBlocks.begin(), ExitBlocks.end()); + LoopInfo &LI = getAnalysis(); for (SetVector::iterator I = ExitBlockSet.begin(), E = ExitBlockSet.end(); I != E; ++I) { BasicBlock *ExitBlock = *I; for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock); PI != PE; ++PI) - if (!L->contains(*PI)) { + // Must be exactly this loop: no subloops, parent loops, or non-loop preds + // allowed. + if (LI.getLoopFor(*PI) != L) { RewriteLoopExitBlock(L, ExitBlock); NumInserted++; Changed = true; @@ -178,6 +180,7 @@ // If the header has more than two predecessors at this point (from the // preheader and from multiple backedges), we must adjust the loop. if (L->getNumBackEdges() != 1) { + // If this is really a nested loop, rip it out into a child loop. if (Loop *NL = SeparateNestedLoop(L)) { ++NumNested; @@ -310,8 +313,8 @@ std::vector OutsideBlocks; for (pred_iterator PI = pred_begin(Header), PE = pred_end(Header); PI != PE; ++PI) - if (!L->contains(*PI)) // Coming in from outside the loop? -OutsideBlocks.push_back(*PI); // Keep track of it... +if (!L->contains(*PI)) // Coming in from outside the loop? + OutsideBlocks.push_back(*PI); // Keep track of it... // Split out the loop pre-header BasicBlock *NewBB = ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/IA64/IA64InstrInfo.td
Changes in directory llvm/lib/Target/IA64: IA64InstrInfo.td updated: 1.45 -> 1.46 --- Log message: now short immediates will get matched (previously constants were all triggering movl 64bit imm fat instructions) --- Diffs of the changes: (+3 -5) IA64InstrInfo.td |8 +++- 1 files changed, 3 insertions(+), 5 deletions(-) Index: llvm/lib/Target/IA64/IA64InstrInfo.td diff -u llvm/lib/Target/IA64/IA64InstrInfo.td:1.45 llvm/lib/Target/IA64/IA64InstrInfo.td:1.46 --- llvm/lib/Target/IA64/IA64InstrInfo.td:1.45 Thu Jan 26 19:46:15 2006 +++ llvm/lib/Target/IA64/IA64InstrInfo.td Sat Feb 11 01:32:15 2006 @@ -99,11 +99,9 @@ return (v <= 8191 && v >= -8192); }]>; -def imm64 : PatLeaf<(i64 imm), [{ - // imm64 predicate - True if the immediate fits in a 64-bit - // field - i.e., true. used to keep movl happy - return true; -}]>; +// imm64 predicate - True if the immediate fits in a 64-bit +// field - i.e., true. used to keep movl happy +def imm64 : PatLeaf<(i64 imm)>; def ADD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2), "add $dst = $src1, $src2", ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/IA64: IA64ISelDAGToDAG.cpp updated: 1.36 -> 1.37 --- Log message: fix storing booleans (grawp missed this one) --- Diffs of the changes: (+3 -3) IA64ISelDAGToDAG.cpp |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp diff -u llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.36 llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.37 --- llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.36 Thu Feb 9 01:17:49 2006 +++ llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp Sat Feb 11 01:33:17 2006 @@ -556,9 +556,9 @@ // then load 1 into the same reg iff the predicate to store is 1 SDOperand Tmp; Select(Tmp, N->getOperand(1)); -CurDAG->getTargetNode(IA64::TPCADDS, MVT::i64, Initial, - CurDAG->getConstant(1, MVT::i64), - Tmp); +Tmp = SDOperand(CurDAG->getTargetNode(IA64::TPCADDS, MVT::i64, Initial, + CurDAG->getConstant(1, MVT::i64), + Tmp), 0); Result = CurDAG->SelectNodeTo(N, Opc, MVT::Other, Address, Tmp, Chain); return; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits