[llvm-commits] [llvm] r40925 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveIntervalAnalysis.cpp

2007-08-08 Thread Evan Cheng
Author: evancheng
Date: Wed Aug  8 02:03:29 2007
New Revision: 40925

URL: http://llvm.org/viewvc/llvm-project?rev=40925&view=rev
Log:
Adding kill info to val#.

Modified:
llvm/trunk/include/llvm/CodeGen/LiveInterval.h
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=40925&r1=40924&r2=40925&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Wed Aug  8 02:03:29 2007
@@ -166,8 +166,23 @@
 /// addKillForValNum - Add a kill instruction index to the specified value
 /// number.
 void addKillForValNum(unsigned ValNo, unsigned KillIdx) {
+  assert(ValNo < ValueNumberInfo.size());
   ValueNumberInfo[ValNo].kills.push_back(KillIdx);
 }
+
+/// replaceKillForValNum - Replace a kill index of the specified value with
+/// a new kill index.
+bool replaceKillForValNum(unsigned ValNo, unsigned OldKill,
+  unsigned NewKill) {
+  SmallVector kills = ValueNumberInfo[ValNo].kills;
+  SmallVector::iterator I =
+std::find(kills.begin(), kills.end(), OldKill);
+  if (I == kills.end())
+return false;
+  kills.erase(I);
+  kills.push_back(NewKill);
+  return true;
+}
 
 VNInfo getValNumInfo(unsigned ValNo) const {
   assert(ValNo < ValueNumberInfo.size());

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=40925&r1=40924&r2=40925&view=diff

==
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Aug  8 02:03:29 2007
@@ -457,6 +457,7 @@
   LiveRange LR(DefIndex, RedefIndex, ValNo);
   DOUT << " replace range with " << LR;
   interval.addRange(LR);
+  interval.addKillForValNum(ValNo, RedefIndex);
 
   // If this redefinition is dead, we need to add a dummy unit live
   // range covering the def slot.
@@ -481,6 +482,8 @@
 DOUT << " Removing [" << Start << "," << End << "] from: ";
 interval.print(DOUT, mri_); DOUT << "\n";
 interval.removeRange(Start, End);
+bool replaced = interval.replaceKillForValNum(0, End, Start);
+assert(replaced && "Incorrect kill info?");
 DOUT << " RESULT: "; interval.print(DOUT, mri_);
 
 // Replace the interval with one of a NEW value number.  Note that this
@@ -488,6 +491,7 @@
 LiveRange LR(Start, End, interval.getNextValue(~0, 0));
 DOUT << " replace range with " << LR;
 interval.addRange(LR);
+interval.addKillForValNum(LR.ValId, End);
 DOUT << " RESULT: "; interval.print(DOUT, mri_);
   }
 
@@ -503,9 +507,10 @@
   else
 ValNum = interval.getNextValue(defIndex, SrcReg);
   
-  LiveRange LR(defIndex,
-   getInstructionIndex(&mbb->back()) + InstrSlots::NUM, 
ValNum);
+  unsigned killIndex = getInstructionIndex(&mbb->back()) + InstrSlots::NUM;
+  LiveRange LR(defIndex, killIndex, ValNum);
   interval.addRange(LR);
+  interval.addKillForValNum(ValNum, killIndex);
   DOUT << " +" << LR;
 }
   }
@@ -570,6 +575,7 @@
 ? OldLR->ValId : interval.getNextValue(start, SrcReg);
   LiveRange LR(start, end, Id);
   interval.addRange(LR);
+  interval.addKillForValNum(LR.ValId, end);
   DOUT << " +" << LR << '\n';
 }
 
@@ -635,8 +641,9 @@
   }
 
   LiveRange LR(start, end, interval.getNextValue(start, 0));
-  DOUT << " +" << LR << '\n';
   interval.addRange(LR);
+  interval.addKillForValNum(LR.ValId, end);
+  DOUT << " +" << LR << '\n';
 }
 
 /// computeIntervals - computes the live intervals for virtual


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40926 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp

2007-08-08 Thread Chris Lattner
Author: lattner
Date: Wed Aug  8 11:07:23 2007
New Revision: 40926

URL: http://llvm.org/viewvc/llvm-project?rev=40926&view=rev
Log:
Handle functions with no name better.

Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=40926&r1=40925&r2=40926&view=diff

==
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed Aug  8 11:07:23 2007
@@ -327,9 +327,9 @@
   }
 
   const ValueName *NameVal = F->getValueName();
+  if (NameVal == 0) return false;
   const char *Str = NameVal->getKeyData();
   unsigned Len = NameVal->getKeyLength();
-  if (Len == 0) return false;
   
   // In these cases, the check of the length is required.  We don't want to
   // return true for a name like "cos\0blah" which strcmp would return equal to
@@ -414,6 +414,7 @@
 Constant *
 llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) 
{
   const ValueName *NameVal = F->getValueName();
+  if (NameVal == 0) return 0;
   const char *Str = NameVal->getKeyData();
   unsigned Len = NameVal->getKeyLength();
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40927 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp

2007-08-08 Thread Chris Lattner
Author: lattner
Date: Wed Aug  8 11:19:57 2007
New Revision: 40927

URL: http://llvm.org/viewvc/llvm-project?rev=40927&view=rev
Log:
eliminate redundant conditions from the signless types conversion.

Modified:
llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=40927&r1=40926&r2=40927&view=diff

==
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Wed Aug  8 11:19:57 2007
@@ -107,11 +107,10 @@
 
   // Handle some common cases first.  These cases correspond to common `main'
   // prototypes.
-  if (RetTy == Type::Int32Ty || RetTy == Type::Int32Ty || RetTy == 
Type::VoidTy) {
+  if (RetTy == Type::Int32Ty || RetTy == Type::VoidTy) {
 switch (ArgValues.size()) {
 case 3:
-  if ((FTy->getParamType(0) == Type::Int32Ty ||
-   FTy->getParamType(0) == Type::Int32Ty) &&
+  if (FTy->getParamType(0) == Type::Int32Ty &&
   isa(FTy->getParamType(1)) &&
   isa(FTy->getParamType(2))) {
 int (*PF)(int, char **, const char **) =
@@ -126,8 +125,7 @@
   }
   break;
 case 2:
-  if ((FTy->getParamType(0) == Type::Int32Ty ||
-   FTy->getParamType(0) == Type::Int32Ty) &&
+  if (FTy->getParamType(0) == Type::Int32Ty &&
   isa(FTy->getParamType(1))) {
 int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr;
 
@@ -140,8 +138,7 @@
   break;
 case 1:
   if (FTy->getNumParams() == 1 &&
-  (FTy->getParamType(0) == Type::Int32Ty ||
-   FTy->getParamType(0) == Type::Int32Ty)) {
+  FTy->getParamType(0) == Type::Int32Ty) {
 GenericValue rv;
 int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
 rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r40927 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp

2007-08-08 Thread Reid Spencer
On Wed, 2007-08-08 at 16:19 +, Chris Lattner wrote:
> Author: lattner
> Date: Wed Aug  8 11:19:57 2007
> New Revision: 40927
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=40927&view=rev
> Log:
> eliminate redundant conditions from the signless types conversion.

And I thought I'd gotten all of those. Thanks!

Reid.

> 
> Modified:
> llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
> 
> Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=40927&r1=40926&r2=40927&view=diff
> 
> ==
> --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Wed Aug  8 11:19:57 2007
> @@ -107,11 +107,10 @@
>  
>// Handle some common cases first.  These cases correspond to common `main'
>// prototypes.
> -  if (RetTy == Type::Int32Ty || RetTy == Type::Int32Ty || RetTy == 
> Type::VoidTy) {
> +  if (RetTy == Type::Int32Ty || RetTy == Type::VoidTy) {
>  switch (ArgValues.size()) {
>  case 3:
> -  if ((FTy->getParamType(0) == Type::Int32Ty ||
> -   FTy->getParamType(0) == Type::Int32Ty) &&
> +  if (FTy->getParamType(0) == Type::Int32Ty &&
>isa(FTy->getParamType(1)) &&
>isa(FTy->getParamType(2))) {
>  int (*PF)(int, char **, const char **) =
> @@ -126,8 +125,7 @@
>}
>break;
>  case 2:
> -  if ((FTy->getParamType(0) == Type::Int32Ty ||
> -   FTy->getParamType(0) == Type::Int32Ty) &&
> +  if (FTy->getParamType(0) == Type::Int32Ty &&
>isa(FTy->getParamType(1))) {
>  int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr;
>  
> @@ -140,8 +138,7 @@
>break;
>  case 1:
>if (FTy->getNumParams() == 1 &&
> -  (FTy->getParamType(0) == Type::Int32Ty ||
> -   FTy->getParamType(0) == Type::Int32Ty)) {
> +  FTy->getParamType(0) == Type::Int32Ty) {
>  GenericValue rv;
>  int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
>  rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
> 
> 
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [test-suite] r40928 - /test-suite/trunk/MultiSource/Applications/hexxagon/Makefile

2007-08-08 Thread Lauro Ramos Venancio
Author: laurov
Date: Wed Aug  8 12:22:53 2007
New Revision: 40928

URL: http://llvm.org/viewvc/llvm-project?rev=40928&view=rev
Log:
hexxagon doesn't need libtermcap.


Modified:
test-suite/trunk/MultiSource/Applications/hexxagon/Makefile

Modified: test-suite/trunk/MultiSource/Applications/hexxagon/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/hexxagon/Makefile?rev=40928&r1=40927&r2=40928&view=diff

==
--- test-suite/trunk/MultiSource/Applications/hexxagon/Makefile (original)
+++ test-suite/trunk/MultiSource/Applications/hexxagon/Makefile Wed Aug  8 
12:22:53 2007
@@ -1,7 +1,7 @@
 LEVEL = ../../..
 PROG = hexxagon
 REQUIRES_EH_SUPPORT = 1
-LDFLAGS += -lstdc++ -ltermcap
-LIBS += -lstdc++ -ltermcap
+LDFLAGS += -lstdc++
+LIBS += -lstdc++
 STDIN_FILENAME=$(PROJ_SRC_DIR)/input
 include ../../Makefile.multisrc


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40932 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 12:50:09 2007
New Revision: 40932

URL: http://llvm.org/viewvc/llvm-project?rev=40932&view=rev
Log:
Add some comments, remove a dead argument, and simplify some control flow.
No functionality change.

Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=40932&r1=40931&r2=40932&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Aug  8 
12:50:09 2007
@@ -51,9 +51,9 @@
 Instruction* dependency,
 SetVector& possiblyDead);
 bool handleEndBlock(BasicBlock& BB, SetVector& possiblyDead);
-bool RemoveUndeadPointers(Value* pointer, unsigned pointerSize,
+bool RemoveUndeadPointers(Value* pointer,
   BasicBlock::iterator& BBI,
-  SmallPtrSet& deadPointers, 
+  SmallPtrSet& deadPointers, 
   SetVector& possiblyDead);
 void DeleteDeadInstructionChains(Instruction *I,
  SetVector &DeadInsts);
@@ -222,7 +222,11 @@
 }
 
 /// handleEndBlock - Remove dead stores to stack-allocated locations in the
-/// function end block
+/// function end block.  Ex:
+/// %A = alloca i32
+/// ...
+/// store i32 1, i32* %A
+/// ret void
 bool DSE::handleEndBlock(BasicBlock& BB,
  SetVector& possiblyDead) {
   TargetData &TD = getAnalysis();
@@ -232,7 +236,7 @@
   bool MadeChange = false;
   
   // Pointers alloca'd in this function are dead in the end block
-  SmallPtrSet deadPointers;
+  SmallPtrSet deadPointers;
   
   // Find all of the alloca'd pointers in the entry block
   BasicBlock *Entry = BB.getParent()->begin();
@@ -247,9 +251,6 @@
 if (deadPointers.empty())
   break;
 
-Value* killPointer = 0;
-unsigned killPointerSize = 0;
-
 // If we find a store whose pointer is dead...
 if (StoreInst* S = dyn_cast(BBI)) {
   Value* pointerOperand = S->getPointerOperand();
@@ -271,24 +272,24 @@
 NumFastStores++;
 MadeChange = true;
   }
+  
+  continue;
+}
+
+Value* killPointer = 0;
 
 // If we encounter a use of the pointer, it is no longer considered dead
-} else if (LoadInst* L = dyn_cast(BBI)) {
+if (LoadInst* L = dyn_cast(BBI)) {
   killPointer = L->getPointerOperand();
-  killPointerSize = TD.getTypeSize(L->getType());
 } else if (VAArgInst* V = dyn_cast(BBI)) {
   killPointer = V->getOperand(0);
-  killPointerSize = TD.getTypeSize(V->getType());
-} else if (FreeInst* F = dyn_cast(BBI)) {
-  killPointer = F->getPointerOperand();
-  killPointerSize = ~0UL;
 } else if (AllocaInst* A = dyn_cast(BBI)) {
   deadPointers.erase(A);
   continue;
 } else if (CallSite::get(BBI).getInstruction() != 0) {
   // Remove any pointers made undead by the call from the dead set
   std::vector dead;
-  for (SmallPtrSet::iterator I = deadPointers.begin(),
+  for (SmallPtrSet::iterator I = deadPointers.begin(),
E = deadPointers.end(); I != E; ++I) {
 // Get size information for the alloca
 unsigned pointerSize = ~0UL;
@@ -314,16 +315,20 @@
   continue;
 
 // Deal with undead pointers
-MadeChange |= RemoveUndeadPointers(killPointer, killPointerSize, BBI,
+MadeChange |= RemoveUndeadPointers(killPointer, BBI,
deadPointers, possiblyDead);
   }
   
   return MadeChange;
 }
 
-bool DSE::RemoveUndeadPointers(Value* killPointer, unsigned killPointerSize,
+/// RemoveUndeadPointers - takes an instruction and a setvector of
+/// dead instructions.  If I is dead, it is erased, and its operands are
+/// checked for deadness.  If they are dead, they are added to the dead
+/// setvector.
+bool DSE::RemoveUndeadPointers(Value* killPointer,
 BasicBlock::iterator& BBI,
-SmallPtrSet& deadPointers, 
+SmallPtrSet& deadPointers, 
 SetVector& possiblyDead) {
   TargetData &TD = getAnalysis();
   AliasAnalysis &AA = getAnalysis();
@@ -333,7 +338,7 @@
   
   std::vector undead;
 
-  for (SmallPtrSet::iterator I = deadPointers.begin(),
+  for (SmallPtrSet::iterator I = deadPointers.begin(),
   E = deadPointers.end(); I != E; ++I) {
 // Get size information for the alloca
 unsigned pointerSize = ~0UL;
@@ -343,7 +348,7 @@
   
 // See if this pointer could alias it
 AliasAnalysis::AliasResult A = AA.alias(*I, pointerSize,
-  

[llvm-commits] [llvm] r40933 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 12:58:56 2007
New Revision: 40933

URL: http://llvm.org/viewvc/llvm-project?rev=40933&view=rev
Log:
Small improvement: if a function doesn't access memory, we don't need to scan
it for potentially undeading pointers.

Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=40933&r1=40932&r2=40933&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Aug  8 
12:58:56 2007
@@ -287,6 +287,13 @@
   deadPointers.erase(A);
   continue;
 } else if (CallSite::get(BBI).getInstruction() != 0) {
+  // If this call does not access memory, it can't
+  // be undeadifying any of our pointers.
+  CallSite CS = CallSite::get(BBI);
+  if (CS.getCalledFunction() &&
+  AA.doesNotAccessMemory(CS.getCalledFunction()))
+continue;
+  
   // Remove any pointers made undead by the call from the dead set
   std::vector dead;
   for (SmallPtrSet::iterator I = deadPointers.begin(),
@@ -298,8 +305,7 @@
 TD.getTypeSize((*I)->getAllocatedType()); 
 
 // See if the call site touches it
-AliasAnalysis::ModRefResult A = AA.getModRefInfo(CallSite::get(BBI),
- *I, pointerSize);
+AliasAnalysis::ModRefResult A = AA.getModRefInfo(CS, *I, pointerSize);
 if (A == AliasAnalysis::ModRef || A == AliasAnalysis::Ref)
   dead.push_back(*I);
   }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [test-suite] r40934 - in /test-suite/trunk/MultiSource/Applications/hexxagon: hexxagon.cpp hexxagonmove.cpp

2007-08-08 Thread Lauro Ramos Venancio
Author: laurov
Date: Wed Aug  8 13:32:57 2007
New Revision: 40934

URL: http://llvm.org/viewvc/llvm-project?rev=40934&view=rev
Log:
- Define SMALL_PROBLEM_SIZE
- Ignore the maxtime to make the test deterministic.


Modified:
test-suite/trunk/MultiSource/Applications/hexxagon/hexxagon.cpp
test-suite/trunk/MultiSource/Applications/hexxagon/hexxagonmove.cpp

Modified: test-suite/trunk/MultiSource/Applications/hexxagon/hexxagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/hexxagon/hexxagon.cpp?rev=40934&r1=40933&r2=40934&view=diff

==
--- test-suite/trunk/MultiSource/Applications/hexxagon/hexxagon.cpp (original)
+++ test-suite/trunk/MultiSource/Applications/hexxagon/hexxagon.cpp Wed Aug  8 
13:32:57 2007
@@ -151,8 +151,11 @@
int quit = 0;

int mode = 1;
-   
-   int level = 4;
+#ifdef SMALL_PROBLEM_SIZE
+int level = 3;
+#else
+int level = 4;
+#endif
int time = 12;

   int llvm_index;

Modified: test-suite/trunk/MultiSource/Applications/hexxagon/hexxagonmove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/hexxagon/hexxagonmove.cpp?rev=40934&r1=40933&r2=40934&view=diff

==
--- test-suite/trunk/MultiSource/Applications/hexxagon/hexxagonmove.cpp 
(original)
+++ test-suite/trunk/MultiSource/Applications/hexxagon/hexxagonmove.cpp Wed Aug 
 8 13:32:57 2007
@@ -158,13 +158,13 @@
 {
int t = getTime();
 
-   for(int i = 1; (i < depth) && (getTime() - t <= maxtime); i++)
+   for(int i = 1; (i < depth)/* && (getTime() - t <= maxtime) */; i++)
{
int best  = -SCR_INFINITY;
int alpha = -SCR_INFINITY;
int beta  = SCR_INFINITY;
 
-   for(int j = 0; (j < getNrMoves()) && (getTime() - t <= maxtime) 
&& (best < beta); j++)
+   for(int j = 0; (j < getNrMoves()) && /* (getTime() - t <= 
maxtime) && */ (best < beta); j++)
{
if(best > alpha)
alpha = best;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40935 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 13:38:28 2007
New Revision: 40935

URL: http://llvm.org/viewvc/llvm-project?rev=40935&view=rev
Log:
Make handleEndBlock significantly faster with one trivial improvement,
and one hack to avoid hitting a bad case when the alias analysis is imprecise.

Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=40935&r1=40934&r2=40935&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Aug  8 
13:38:28 2007
@@ -294,10 +294,22 @@
   AA.doesNotAccessMemory(CS.getCalledFunction()))
 continue;
   
+  unsigned modRef = 0;
+  unsigned other = 0;
+  
   // Remove any pointers made undead by the call from the dead set
   std::vector dead;
   for (SmallPtrSet::iterator I = deadPointers.begin(),
E = deadPointers.end(); I != E; ++I) {
+// HACK: if we detect that our AA is imprecise, it's not
+// worth it to scan the rest of the deadPointers set.  Just
+// assume that the AA will return ModRef for everything, and
+// go ahead and bail.
+if (modRef >= 16 && other == 0) {
+  deadPointers.clear();
+  return MadeChange;
+}
+
 // Get size information for the alloca
 unsigned pointerSize = ~0UL;
 if (ConstantInt* C = dyn_cast((*I)->getArraySize()))
@@ -306,6 +318,12 @@
 
 // See if the call site touches it
 AliasAnalysis::ModRefResult A = AA.getModRefInfo(CS, *I, pointerSize);
+
+if (A == AliasAnalysis::ModRef)
+  modRef++;
+else
+  other++;
+
 if (A == AliasAnalysis::ModRef || A == AliasAnalysis::Ref)
   dead.push_back(*I);
   }
@@ -320,6 +338,8 @@
 if (!killPointer)
   continue;
 
+TranslatePointerBitCasts(killPointer);
+
 // Deal with undead pointers
 MadeChange |= RemoveUndeadPointers(killPointer, BBI,
deadPointers, possiblyDead);
@@ -328,10 +348,8 @@
   return MadeChange;
 }
 
-/// RemoveUndeadPointers - takes an instruction and a setvector of
-/// dead instructions.  If I is dead, it is erased, and its operands are
-/// checked for deadness.  If they are dead, they are added to the dead
-/// setvector.
+/// RemoveUndeadPointers - check for uses of a pointer that make it
+/// undead when scanning for dead stores to alloca's.
 bool DSE::RemoveUndeadPointers(Value* killPointer,
 BasicBlock::iterator& BBI,
 SmallPtrSet& deadPointers, 
@@ -340,6 +358,14 @@
   AliasAnalysis &AA = getAnalysis();
   MemoryDependenceAnalysis& MD = getAnalysis();
   
+  // If the kill pointer can be easily reduced to an alloca,
+  // don't bother doing extraneous AA queries
+  if (AllocaInst* A = dyn_cast(killPointer)) {
+if (deadPointers.count(A))
+  deadPointers.erase(A);
+return false;
+  }
+  
   bool MadeChange = false;
   
   std::vector undead;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40936 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 14:12:31 2007
New Revision: 40936

URL: http://llvm.org/viewvc/llvm-project?rev=40936&view=rev
Log:
Global values also don't undead-ify pointers in our dead alloca's set.

Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=40936&r1=40935&r2=40936&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Aug  8 
14:12:31 2007
@@ -364,6 +364,9 @@
 if (deadPointers.count(A))
   deadPointers.erase(A);
 return false;
+  } else if (isa(killPointer)) {
+// A global can't be in the dead pointer set
+return false;
   }
   
   bool MadeChange = false;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [test-suite] r40937 [3/5] - in /test-suite/trunk/MultiSource/Applications/minisat: Main.cpp Makefile long.cnf long.cnf.gz short.cnf short.cnf.gz small.cnf small.cnf.gz

2007-08-08 Thread Lauro Ramos Venancio
Removed: test-suite/trunk/MultiSource/Applications/minisat/long.cnf.gz
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/minisat/long.cnf.gz?rev=40936&view=auto

==
Binary file - no diff available.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [test-suite] r40937 [1/5] - in /test-suite/trunk/MultiSource/Applications/minisat: Main.cpp Makefile long.cnf long.cnf.gz short.cnf short.cnf.gz small.cnf small.cnf.gz

2007-08-08 Thread Lauro Ramos Venancio
Author: laurov
Date: Wed Aug  8 14:30:23 2007
New Revision: 40937

URL: http://llvm.org/viewvc/llvm-project?rev=40937&view=rev
Log:
Removed the need for zlib.


Added:
test-suite/trunk/MultiSource/Applications/minisat/long.cnf
test-suite/trunk/MultiSource/Applications/minisat/short.cnf
test-suite/trunk/MultiSource/Applications/minisat/small.cnf
Removed:
test-suite/trunk/MultiSource/Applications/minisat/long.cnf.gz
test-suite/trunk/MultiSource/Applications/minisat/short.cnf.gz
test-suite/trunk/MultiSource/Applications/minisat/small.cnf.gz
Modified:
test-suite/trunk/MultiSource/Applications/minisat/Main.cpp
test-suite/trunk/MultiSource/Applications/minisat/Makefile

Modified: test-suite/trunk/MultiSource/Applications/minisat/Main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/minisat/Main.cpp?rev=40937&r1=40936&r2=40937&view=diff

==
--- test-suite/trunk/MultiSource/Applications/minisat/Main.cpp (original)
+++ test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Wed Aug  8 
14:30:23 2007
@@ -23,7 +23,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 #include "Solver.h"
 
@@ -84,7 +84,7 @@
 #define CHUNK_LIMIT 1048576
 
 class StreamBuffer {
-gzFile  in;
+FILE   *in;
 charbuf[CHUNK_LIMIT];
 int pos;
 int size;
@@ -92,10 +92,10 @@
 void assureLookahead() {
 if (pos >= size) {
 pos  = 0;
-size = gzread(in, buf, sizeof(buf)); } }
+size = read(fileno(in), buf, sizeof(buf)); } }
 
 public:
-StreamBuffer(gzFile i) : in(i), pos(0), size(0) {
+StreamBuffer(FILE *i) : in(i), pos(0), size(0) {
 assureLookahead(); }
 
 int  operator *  () { return (pos >= size) ? EOF : buf[pos]; }
@@ -177,7 +177,7 @@
 
 // Inserts problem into solver.
 //
-static void parse_DIMACS(gzFile input_stream, Solver& S) {
+static void parse_DIMACS(FILE *input_stream, Solver& S) {
 StreamBuffer in(input_stream);
 parse_DIMACS_main(in, S); }
 
@@ -300,7 +300,7 @@
 if (argc == 1)
 reportf("Reading from standard input... Use '-h' or '--help' for 
help.\n");
 
-gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb");
+FILE *in = (argc == 1) ? stdin : fopen(argv[1], "rb");
 if (in == NULL)
 reportf("ERROR! Could not open file: %s\n", argc == 1 ? "" : 
argv[1]), exit(1);
 
@@ -308,7 +308,7 @@
 reportf("| 
|\n");
 
 parse_DIMACS(in, S);
-gzclose(in);
+fclose(in);
 FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;
 
 if (!S.simplify()){

Modified: test-suite/trunk/MultiSource/Applications/minisat/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/minisat/Makefile?rev=40937&r1=40936&r2=40937&view=diff

==
--- test-suite/trunk/MultiSource/Applications/minisat/Makefile (original)
+++ test-suite/trunk/MultiSource/Applications/minisat/Makefile Wed Aug  8 
14:30:23 2007
@@ -3,14 +3,14 @@
 LEVEL = ../../..
 PROG = minisat
 CPPFLAGS = -D NDEBUG
-LDFLAGS = -lz -lstdc++ -lm
+LDFLAGS = -lstdc++ -lm
 ifdef SMALL_PROBLEM_SIZE
-RUN_OPTIONS = -verbosity=0 $(PROJ_SRC_DIR)/small.cnf.gz
+RUN_OPTIONS = -verbosity=0 $(PROJ_SRC_DIR)/small.cnf
 else
 ifdef LARGE_PROBLEM_SIZE
-RUN_OPTIONS = -verbosity=0 $(PROJ_SRC_DIR)/long.cnf.gz
+RUN_OPTIONS = -verbosity=0 $(PROJ_SRC_DIR)/long.cnf
 else
-RUN_OPTIONS = -verbosity=0 $(PROJ_SRC_DIR)/short.cnf.gz
+RUN_OPTIONS = -verbosity=0 $(PROJ_SRC_DIR)/short.cnf
 endif
 endif
 FP_TOLERANCE = 0.1


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40938 - /llvm/trunk/lib/Linker/LinkItems.cpp

2007-08-08 Thread Reid Spencer
Author: reid
Date: Wed Aug  8 14:52:29 2007
New Revision: 40938

URL: http://llvm.org/viewvc/llvm-project?rev=40938&view=rev
Log:
Allow the filename "-" to be a place holder for stdin. This allows directing
stdin through llvm-ld and llvm-link.

Modified:
llvm/trunk/lib/Linker/LinkItems.cpp

Modified: llvm/trunk/lib/Linker/LinkItems.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkItems.cpp?rev=40938&r1=40937&r2=40938&view=diff

==
--- llvm/trunk/lib/Linker/LinkItems.cpp (original)
+++ llvm/trunk/lib/Linker/LinkItems.cpp Wed Aug  8 14:52:29 2007
@@ -14,6 +14,8 @@
 
 #include "llvm/Linker.h"
 #include "llvm/Module.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Bitcode/ReaderWriter.h"
 
 using namespace llvm;
 
@@ -153,6 +155,20 @@
 ///
 bool Linker::LinkInFile(const sys::Path &File, bool &is_native) {
   is_native = false;
+  
+  // Check for a file of name "-", which means "read standard input"
+  if (File.toString() == "-") {
+std::auto_ptr M;
+if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN()) {
+  M.reset(ParseBitcodeFile(Buffer, &Error));
+  delete Buffer;
+  if (!LinkInModule(M.get()))
+return false;
+} else 
+  Error = "standard input is empty";
+return error("Cannot link stdin: " + Error);
+  }
+
   // Make sure we can at least read the file
   if (!File.canRead())
 return error("Cannot find linker input '" + File.toString() + "'");


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40939 - /llvm/trunk/lib/Support/MemoryBuffer.cpp

2007-08-08 Thread Reid Spencer
Author: reid
Date: Wed Aug  8 15:01:58 2007
New Revision: 40939

URL: http://llvm.org/viewvc/llvm-project?rev=40939&view=rev
Log:
Make getSTDIN return null if the standard input is empty, as the header file
documentation implies and as its uses depend.

Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp

Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=40939&r1=40938&r2=40939&view=diff

==
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Aug  8 15:01:58 2007
@@ -248,11 +248,13 @@
   
   // Read in all of the data from stdin, we cannot mmap stdin.
   sys::Program::ChangeStdinToBinary();
-  while (size_t ReadBytes = fread(Buffer, 1, 4096*4, stdin))
+  while (size_t ReadBytes = fread(Buffer, sizeof(char), 4096*4, stdin))
 FileData.insert(FileData.end(), Buffer, Buffer+ReadBytes);
-  
+
   FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end().
   size_t Size = FileData.size();
+  if (Size <= 1)
+return 0;
   MemoryBuffer *B = new STDINBufferFile();
   B->initCopyOf(&FileData[0], &FileData[Size-1]);
   return B;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40940 - /llvm/trunk/include/llvm/Support/MemoryBuffer.h

2007-08-08 Thread Reid Spencer
Author: reid
Date: Wed Aug  8 15:02:20 2007
New Revision: 40940

URL: http://llvm.org/viewvc/llvm-project?rev=40940&view=rev
Log:
Make it clear that getSTDIN returns null when stdin is empty.

Modified:
llvm/trunk/include/llvm/Support/MemoryBuffer.h

Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=40940&r1=40939&r2=40940&view=diff

==
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Wed Aug  8 15:02:20 2007
@@ -76,7 +76,7 @@
  const char *BufferName = "");
   
   /// getSTDIN - Read all of stdin into a file buffer, and return it.  This
-  /// fails if stdin is empty.
+  /// returns null if stdin is empty.
   static MemoryBuffer *getSTDIN();
   
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40941 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

2007-08-08 Thread Devang Patel
Author: dpatel
Date: Wed Aug  8 16:02:17 2007
New Revision: 40941

URL: http://llvm.org/viewvc/llvm-project?rev=40941&view=rev
Log:
Handle multiple split conditions.

Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40941&r1=40940&r2=40941&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Aug  8 16:02:17 2007
@@ -46,6 +46,28 @@
 }
 
   private:
+
+class SplitInfo {
+public:
+  SplitInfo() : IndVar(NULL), SplitValue(NULL), ExitValue(NULL),
+SplitCondition(NULL), ExitCondition(NULL) {}
+  // Induction variable whose range is being split by this transformation.
+  PHINode *IndVar;
+  
+  // Induction variable's range is split at this value.
+  Value *SplitValue;
+  
+  // Induction variable's final loop exit value.
+  Value *ExitValue;
+  
+  // This compare instruction compares IndVar against SplitValue.
+  ICmpInst *SplitCondition;
+
+  // Loop exit condition.
+  ICmpInst *ExitCondition;
+};
+
+  private:
 /// Find condition inside a loop that is suitable candidate for index 
split.
 void findSplitCondition();
 
@@ -54,17 +76,17 @@
 /// entire (i.e. meaningful) loop body is dominated by this compare
 /// instruction then loop body is executed only for one iteration. In
 /// such case eliminate loop structure surrounding this loop body. For
-bool processOneIterationLoop(LPPassManager &LPM);
+bool processOneIterationLoop(SplitInfo &SD, LPPassManager &LPM);
 
 // If loop header includes loop variant instruction operands then
 // this loop may not be eliminated.
-bool safeHeader(BasicBlock *BB);
+bool safeHeader(SplitInfo &SD,  BasicBlock *BB);
 
 // If Exit block includes loop variant instructions then this
 // loop may not be eliminated.
-bool safeExitBlock(BasicBlock *BB);
+bool safeExitBlock(SplitInfo &SD, BasicBlock *BB);
 
-bool splitLoop();
+bool splitLoop(SplitInfo &SD);
 
   private:
 
@@ -72,20 +94,7 @@
 Loop *L;
 ScalarEvolution *SE;
 
-// Induction variable whose range is being split by this transformation.
-PHINode *IndVar;
-
-// Induction variable's range is split at this value.
-Value *SplitValue;
-
-// Induction variable's final loop exit value.
-Value *ExitValue;
-
-// This compare instruction compares IndVar against SplitValue.
-ICmpInst *SplitCondition;
-
-// Loop exit condition.
-ICmpInst *ExitCondition;
+SmallVector SplitData;
   };
 
   char LoopIndexSplit::ID = 0;
@@ -100,30 +109,51 @@
 bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM) {
   bool Changed = false;
   L = IncomingLoop;
-  SplitCondition = NULL;
+
   SE = &getAnalysis();
 
   findSplitCondition();
 
-  if (!SplitCondition)
+  if (SplitData.empty())
 return false;
 
-  if (SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) 
-// If it is possible to eliminate loop then do so.
-Changed = processOneIterationLoop(LPM);
-  else
-Changed = splitLoop();
+  // First see if it is possible to eliminate loop itself or not.
+  for (SmallVector::iterator SI = SplitData.begin(),
+ E = SplitData.end(); SI != E; ++SI) {
+SplitInfo &SD = *SI;
+if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) {
+  Changed = processOneIterationLoop(SD,LPM);
+  if (Changed) {
+++NumIndexSplit;
+// If is loop is eliminated then nothing else to do here.
+return Changed;
+  }
+}
+  }
+
+  for (SmallVector::iterator SI = SplitData.begin(),
+ E = SplitData.end(); SI != E; ++SI) {
+SplitInfo &SD = *SI;
+
+// ICM_EQs are already handled above.
+if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) 
+  continue;
+
+// FIXME : Collect Spliting cost for all SD. Only operate on profitable 
SDs.
+Changed = splitLoop(SD);
+  }
 
   if (Changed)
 ++NumIndexSplit;
-
+  
   return Changed;
 }
 
 /// Find condition inside a loop that is suitable candidate for index split.
 void LoopIndexSplit::findSplitCondition() {
 
- BasicBlock *Header = L->getHeader();
+  SplitInfo SD;
+  BasicBlock *Header = L->getHeader();
 
   for (BasicBlock::iterator I = Header->begin(); isa(I); ++I) {
 PHINode *PN = cast(I);
@@ -140,29 +170,29 @@
 for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end(); 
  UI != E; ++UI) {
   if (ICmpInst *CI = dyn_cast(*UI)) {
-SplitCondition = CI;
+SD.SplitCondition = CI;
 break;
   }
 }
 
 // Valid SplitCondition's one operand is phi node and the other operand
 // is loop invariant.
-if (Spli

[llvm-commits] [test-suite] r40942 - /test-suite/trunk/MultiSource/Applications/obsequi/Makefile

2007-08-08 Thread Lauro Ramos Venancio
Author: laurov
Date: Wed Aug  8 16:07:22 2007
New Revision: 40942

URL: http://llvm.org/viewvc/llvm-project?rev=40942&view=rev
Log:
- Define SMALL_PROBLEM_SIZE
- This test doesn't need libcurses


Modified:
test-suite/trunk/MultiSource/Applications/obsequi/Makefile

Modified: test-suite/trunk/MultiSource/Applications/obsequi/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/obsequi/Makefile?rev=40942&r1=40941&r2=40942&view=diff

==
--- test-suite/trunk/MultiSource/Applications/obsequi/Makefile (original)
+++ test-suite/trunk/MultiSource/Applications/obsequi/Makefile Wed Aug  8 
16:07:22 2007
@@ -1,9 +1,16 @@
 LEVEL = ../../..
 PROG = Obsequi
-CPPFLAGS += -DCOUNTBITS16 -DLASTBIT16 -DCOUNTMOVES_TABLE -DHASHCODEBITS=23
+CPPFLAGS += -DCOUNTBITS16 -DLASTBIT16 -DCOUNTMOVES_TABLE
 CPPFLAGS += -DTWO_STAGE_GENERATION
-LDFLAGS = -lsupc++ -lcurses
-LIBS += -lsupc++ -lcurses
+
+ifdef SMALL_PROBLEM_SIZE
+CPPFLAGS += -DHASHCODEBITS=15
+else
+CPPFLAGS += -DHASHCODEBITS=23
+endif
+
+LDFLAGS = -lsupc++
+LIBS += -lsupc++
 STDIN_FILENAME=$(PROJ_SRC_DIR)/input
 PROGRAM_REQUIRED_TO_EXIT_OK := 1
 include ../../Makefile.multisrc


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40943 - /llvm/trunk/tools/llvm-extract/llvm-extract.cpp

2007-08-08 Thread Reid Spencer
Author: reid
Date: Wed Aug  8 16:17:59 2007
New Revision: 40943

URL: http://llvm.org/viewvc/llvm-project?rev=40943&view=rev
Log:
Terminate an error message with a newline.

Modified:
llvm/trunk/tools/llvm-extract/llvm-extract.cpp

Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=40943&r1=40942&r2=40943&view=diff

==
--- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)
+++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Wed Aug  8 16:17:59 2007
@@ -59,7 +59,7 @@
   
   MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename);
   if (Buffer == 0) {
-cerr << "Error reading file '" + InputFilename + "'";
+cerr << argv[0] << "Error reading file '" + InputFilename + "'\n";
 return 1;
   } else {
 M.reset(ParseBitcodeFile(Buffer));


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40944 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

2007-08-08 Thread Devang Patel
Author: dpatel
Date: Wed Aug  8 16:18:27 2007
New Revision: 40944

URL: http://llvm.org/viewvc/llvm-project?rev=40944&view=rev
Log:
Clear split info.

Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40944&r1=40943&r2=40944&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Aug  8 16:18:27 2007
@@ -65,6 +65,15 @@
 
   // Loop exit condition.
   ICmpInst *ExitCondition;
+
+  // Clear split info.
+  void clear() {
+IndVar = NULL;
+SplitValue = NULL;
+ExitValue = NULL;
+SplitCondition = NULL;
+ExitCondition = NULL;
+  }
 };
 
   private:
@@ -193,6 +202,8 @@
 if (SD.SplitCondition) {
   SD.IndVar = PN;
   SplitData.push_back(SD);
+  // Before reusing SD for next split condition clear its content.
+  SD.clear();
 }
   }
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40945 - /llvm/trunk/tools/llvm-extract/llvm-extract.cpp

2007-08-08 Thread Reid Spencer
Author: reid
Date: Wed Aug  8 16:19:01 2007
New Revision: 40945

URL: http://llvm.org/viewvc/llvm-project?rev=40945&view=rev
Log:
Separate program name from error message with a :

Modified:
llvm/trunk/tools/llvm-extract/llvm-extract.cpp

Modified: llvm/trunk/tools/llvm-extract/llvm-extract.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-extract/llvm-extract.cpp?rev=40945&r1=40944&r2=40945&view=diff

==
--- llvm/trunk/tools/llvm-extract/llvm-extract.cpp (original)
+++ llvm/trunk/tools/llvm-extract/llvm-extract.cpp Wed Aug  8 16:19:01 2007
@@ -59,7 +59,7 @@
   
   MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename);
   if (Buffer == 0) {
-cerr << argv[0] << "Error reading file '" + InputFilename + "'\n";
+cerr << argv[0] << ": Error reading file '" + InputFilename + "'\n";
 return 1;
   } else {
 M.reset(ParseBitcodeFile(Buffer));


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40946 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/DeadStoreElimination.cpp lib/Transforms/

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 16:39:39 2007
New Revision: 40946

URL: http://llvm.org/viewvc/llvm-project?rev=40946&view=rev
Log:
Change the None and NonLocal markers in memdep to be const.

Modified:
llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/lib/Transforms/Scalar/RedundantLoadElimination.cpp

Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=40946&r1=40945&r2=40946&view=diff

==
--- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Wed Aug  8 
16:39:39 2007
@@ -32,23 +32,23 @@
 class MemoryDependenceAnalysis : public FunctionPass {
   private:
 
-typedef DenseMap > 
+typedef DenseMap > 
 depMapType;
 
 depMapType depGraphLocal;
 
-typedef DenseMap > reverseDepMapType;
 reverseDepMapType reverseDep;
   
-Instruction* getCallSiteDependency(CallSite C, Instruction* start,
+const Instruction* getCallSiteDependency(CallSite C, Instruction* start,
BasicBlock* block);
 void nonLocalHelper(Instruction* query, BasicBlock* block,
 DenseMap& resp);
   public:
 
-static Instruction* NonLocal;
-static Instruction* None;
+static const Instruction* NonLocal;
+static const Instruction* None;
 
 static char ID; // Class identification, replacement for typeinfo
 MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
@@ -70,7 +70,7 @@
 
 /// getDependency - Return the instruction on which a memory operation
 /// depends, starting with start.
-Instruction* getDependency(Instruction* query, Instruction* start = 0,
+const Instruction* getDependency(Instruction* query, Instruction* start = 
0,
BasicBlock* block = 0);
 
 void getNonLocalDependency(Instruction* query,

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=40946&r1=40945&r2=40946&view=diff

==
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Aug  8 16:39:39 
2007
@@ -26,8 +26,8 @@
 
 char MemoryDependenceAnalysis::ID = 0;
   
-Instruction* MemoryDependenceAnalysis::NonLocal = (Instruction*)-3;
-Instruction* MemoryDependenceAnalysis::None = (Instruction*)-4;
+const Instruction* MemoryDependenceAnalysis::NonLocal = (Instruction*)-3;
+const Instruction* MemoryDependenceAnalysis::None = (Instruction*)-4;
   
 // Register this pass...
 static RegisterPass X("memdep",
@@ -42,7 +42,7 @@
 }
 
 // Find the dependency of a CallSite
-Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, 
Instruction* start,
+const Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, 
Instruction* start,
  BasicBlock* 
block) {
   
   AliasAnalysis& AA = getAnalysis();
@@ -132,9 +132,9 @@
 if (BB != block) {
   visited.insert(BB);
   
-  Instruction* localDep = getDependency(query, 0, BB);
+  const Instruction* localDep = getDependency(query, 0, BB);
   if (localDep != NonLocal) {
-resp.insert(std::make_pair(BB, localDep));
+resp.insert(std::make_pair(BB, const_cast(localDep)));
 stack.pop_back();
 
 continue;
@@ -142,9 +142,9 @@
 } else if (BB == block && stack.size() > 1) {
   visited.insert(BB);
   
-  Instruction* localDep = getDependency(query, 0, BB);
+  const Instruction* localDep = getDependency(query, 0, BB);
   if (localDep != query)
-resp.insert(std::make_pair(BB, localDep));
+resp.insert(std::make_pair(BB, const_cast(localDep)));
   
   stack.pop_back();
   
@@ -164,9 +164,9 @@
 if (inserted)
   continue;
 else if (!inserted && !predOnStack) {
-  resp.insert(std::make_pair(BB, None));
+  resp.insert(std::make_pair(BB, const_cast(None)));
 } else if (!inserted && predOnStack){
-  resp.insert(std::make_pair(BB, NonLocal));
+  resp.insert(std::make_pair(BB, const_cast(NonLocal)));
 }
 
 stack.pop_back();
@@ -175,9 +175,9 @@
 
 void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query,
  DenseMap& resp) {
-  Instruction* localDep = getDependency(query);
+  const Instruction* localDep = getDependency(query);
   if (localDep != NonLo

[llvm-commits] [llvm] r40947 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

2007-08-08 Thread Devang Patel
Author: dpatel
Date: Wed Aug  8 16:39:47 2007
New Revision: 40947

URL: http://llvm.org/viewvc/llvm-project?rev=40947&view=rev
Log:
Preserve dom info while processing one iteration loop.

Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40947&r1=40946&r2=40947&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Aug  8 16:39:47 2007
@@ -17,6 +17,7 @@
 #include "llvm/Function.h"
 #include "llvm/Analysis/LoopPass.h"
 #include "llvm/Analysis/ScalarEvolutionExpander.h"
+#include "llvm/Analysis/Dominators.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/ADT/Statistic.h"
 
@@ -43,6 +44,8 @@
   AU.addPreserved();
   AU.addRequiredID(LoopSimplifyID);
   AU.addPreservedID(LoopSimplifyID);
+  AU.addPreserved();
+  AU.addPreserved();
 }
 
   private:
@@ -314,6 +317,20 @@
   }
 
   LPM.deleteLoopFromQueue(L);
+
+  // Update Dominator Info.
+  // Only CFG change done is to remove Latch to Header edge. This
+  // does not change dominator tree because Latch did not dominate
+  // Header.
+  if (DominanceFrontier *DF = getAnalysisToUpdate()) {
+DominanceFrontier::iterator HeaderDF = DF->find(Header);
+if (HeaderDF != DF->end()) 
+  DF->removeFromFrontier(HeaderDF, Header);
+
+DominanceFrontier::iterator LatchDF = DF->find(Latch);
+if (LatchDF != DF->end()) 
+  DF->removeFromFrontier(LatchDF, Header);
+  }
   return true;
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40948 - /llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 16:53:20 2007
New Revision: 40948

URL: http://llvm.org/viewvc/llvm-project?rev=40948&view=rev
Log:
Cleanup and comment-ize the memdep header.

Modified:
llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h

Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=40948&r1=40947&r2=40948&view=diff

==
--- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Wed Aug  8 
16:53:20 2007
@@ -31,23 +31,24 @@
 
 class MemoryDependenceAnalysis : public FunctionPass {
   private:
-
+// A map from instructions to their dependency, with a boolean
+// flags for whether this mapping is confirmed or not
 typedef DenseMap > 
-depMapType;
-
+depMapType;
 depMapType depGraphLocal;
 
-typedef DenseMap > reverseDepMapType;
+// A reverse mapping form dependencies to the dependees.  This is
+// used when removing instructions to keep the cache coherent.
+typedef DenseMap >
+reverseDepMapType;
 reverseDepMapType reverseDep;
-  
-const Instruction* getCallSiteDependency(CallSite C, Instruction* start,
-   BasicBlock* block);
-void nonLocalHelper(Instruction* query, BasicBlock* block,
-DenseMap& resp);
-  public:
 
+  public:
+// Special marker indicating that the query has no dependency
+// in the specified block.
 static const Instruction* NonLocal;
+
+// Special marker indicating that the query has no dependency at all
 static const Instruction* None;
 
 static char ID; // Class identification, replacement for typeinfo
@@ -79,6 +80,12 @@
 /// removeInstruction - Remove an instruction from the dependence analysis,
 /// updating the dependence of instructions that previously depended on it.
 void removeInstruction(Instruction* rem);
+
+  private:
+const Instruction* getCallSiteDependency(CallSite C, Instruction* start,
+   BasicBlock* block);
+void nonLocalHelper(Instruction* query, BasicBlock* block,
+DenseMap& resp);
   };
 
 } // End llvm namespace


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40949 - /llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 16:54:33 2007
New Revision: 40949

URL: http://llvm.org/viewvc/llvm-project?rev=40949&view=rev
Log:
Add one more comment.

Modified:
llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h

Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=40949&r1=40948&r2=40949&view=diff

==
--- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Wed Aug  8 
16:54:33 2007
@@ -74,6 +74,9 @@
 const Instruction* getDependency(Instruction* query, Instruction* start = 
0,
BasicBlock* block = 0);
 
+/// getNonLocalDependency - Fills the passed-in map with the non-local 
+/// dependencies of the queries.  The map will contain NonLocal for
+/// blocks between the query and its dependencies.
 void getNonLocalDependency(Instruction* query,
DenseMap& resp);
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40950 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 17:01:54 2007
New Revision: 40950

URL: http://llvm.org/viewvc/llvm-project?rev=40950&view=rev
Log:
Make memdep fit in 80 cols.

Modified:
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=40950&r1=40949&r2=40950&view=diff

==
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Aug  8 17:01:54 
2007
@@ -9,7 +9,7 @@
 //
 // This file implements an analysis that determines, for a given memory
 // operation, what preceding memory operations it depends on.  It builds on 
-// alias analysis information, and tries to provide a lazy, caching interface 
to 
+// alias analysis information, and tries to provide a lazy, caching interface 
to
 // a common kind of alias information query.
 //
 
//===--===//
@@ -42,8 +42,9 @@
 }
 
 // Find the dependency of a CallSite
-const Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, 
Instruction* start,
- BasicBlock* 
block) {
+const Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
+   Instruction* start,
+BasicBlock* block) 
{
   
   AliasAnalysis& AA = getAnalysis();
   TargetData& TD = getAnalysis();
@@ -73,7 +74,8 @@
 } else if (AllocationInst* AI = dyn_cast(QI)) {
   pointer = AI;
   if (ConstantInt* C = dyn_cast(AI->getArraySize()))
-pointerSize = C->getZExtValue() * 
TD.getTypeSize(AI->getAllocatedType());
+pointerSize = C->getZExtValue() * \
+  TD.getTypeSize(AI->getAllocatedType());
   else
 pointerSize = ~0UL;
 } else if (VAArgInst* V = dyn_cast(QI)) {
@@ -109,14 +111,15 @@
   }
   
   // No dependence found
-  depGraphLocal.insert(std::make_pair(C.getInstruction(), 
std::make_pair(NonLocal, true)));
+  depGraphLocal.insert(std::make_pair(C.getInstruction(),
+  std::make_pair(NonLocal, true)));
   reverseDep[NonLocal].insert(C.getInstruction());
   return NonLocal;
 }
 
 void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
   BasicBlock* block,
-  DenseMap& 
resp) {
+ DenseMap& resp) {
   SmallPtrSet visited;
   SmallVector stack;
   stack.push_back(block);
@@ -173,11 +176,15 @@
   }
 }
 
+/// getNonLocalDependency - Fills the passed-in map with the non-local 
+/// dependencies of the queries.  The map will contain NonLocal for
+/// blocks between the query and its dependencies.
 void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query,
- DenseMap& resp) {
+ DenseMap& resp) {
   const Instruction* localDep = getDependency(query);
   if (localDep != NonLocal) {
-resp.insert(std::make_pair(query->getParent(), 
const_cast(localDep)));
+resp.insert(std::make_pair(query->getParent(),
+   const_cast(localDep)));
 return;
   }
   
@@ -275,7 +282,8 @@
 } else if (AllocationInst* AI = dyn_cast(QI)) {
   pointer = AI;
   if (ConstantInt* C = dyn_cast(AI->getArraySize()))
-pointerSize = C->getZExtValue() * 
TD.getTypeSize(AI->getAllocatedType());
+pointerSize = C->getZExtValue() * \
+  TD.getTypeSize(AI->getAllocatedType());
   else
 pointerSize = ~0UL;
 } else if (VAArgInst* V = dyn_cast(QI)) {
@@ -287,7 +295,7 @@
   // FreeInsts erase the entire structure
   pointerSize = ~0UL;
 } else if (CallSite::get(QI).getInstruction() != 0) {
-  // Call insts need special handling.  Check is they can modify our 
pointer
+  // Call insts need special handling. Check if they can modify our pointer
   AliasAnalysis::ModRefResult MR = AA.getModRefInfo(CallSite::get(QI),
   dependee, dependeeSize);
   
@@ -297,7 +305,8 @@
   continue;
 
 if (!start && !block) {
-  depGraphLocal.insert(std::make_pair(query, std::make_pair(QI, 
true)));
+  depGraphLocal.insert(std::make_pair(query,
+  std::make_pair(QI, true)));
   reverseDep[QI].insert(query);
 }
 
@@ -319,7 +328,8 @@
   continue;
 
 if (!start && !block) {
-  depGraphLocal.insert(std::make_pair(query, std::make_pair(QI, 
true)));
+  depGraph

[llvm-commits] [llvm] r40952 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

2007-08-08 Thread Devang Patel
Author: dpatel
Date: Wed Aug  8 17:25:28 2007
New Revision: 40952

URL: http://llvm.org/viewvc/llvm-project?rev=40952&view=rev
Log:
Add cost analysis.

Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40952&r1=40951&r2=40952&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Aug  8 17:25:28 2007
@@ -44,6 +44,7 @@
   AU.addPreserved();
   AU.addRequiredID(LoopSimplifyID);
   AU.addPreservedID(LoopSimplifyID);
+  AU.addRequired();
   AU.addPreserved();
   AU.addPreserved();
 }
@@ -90,14 +91,16 @@
 /// such case eliminate loop structure surrounding this loop body. For
 bool processOneIterationLoop(SplitInfo &SD, LPPassManager &LPM);
 
-// If loop header includes loop variant instruction operands then
-// this loop may not be eliminated.
+/// If loop header includes loop variant instruction operands then
+/// this loop may not be eliminated.
 bool safeHeader(SplitInfo &SD,  BasicBlock *BB);
 
-// If Exit block includes loop variant instructions then this
-// loop may not be eliminated.
+/// If Exit block includes loop variant instructions then this
+/// loop may not be eliminated.
 bool safeExitBlock(SplitInfo &SD, BasicBlock *BB);
 
+/// Find cost of spliting loop L.
+unsigned findSplitCost(Loop *L, SplitInfo &SD);
 bool splitLoop(SplitInfo &SD);
 
   private:
@@ -105,7 +108,7 @@
 // Current Loop.
 Loop *L;
 ScalarEvolution *SE;
-
+DominatorTree *DT;
 SmallVector SplitData;
   };
 
@@ -123,6 +126,7 @@
   L = IncomingLoop;
 
   SE = &getAnalysis();
+  DT = &getAnalysis();
 
   findSplitCondition();
 
@@ -143,18 +147,25 @@
 }
   }
 
+  unsigned MaxCost = 99;
+  unsigned Index = 0;
+  unsigned MostProfitableSDIndex = 0;
   for (SmallVector::iterator SI = SplitData.begin(),
- E = SplitData.end(); SI != E; ++SI) {
-SplitInfo &SD = *SI;
+ E = SplitData.end(); SI != E; ++SI, ++Index) {
+SplitInfo SD = *SI;
 
 // ICM_EQs are already handled above.
-if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) 
+if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ)
   continue;
-
-// FIXME : Collect Spliting cost for all SD. Only operate on profitable 
SDs.
-Changed = splitLoop(SD);
+
+unsigned Cost = findSplitCost(L, SD);
+if (Cost < MaxCost)
+  MostProfitableSDIndex = Index;
   }
 
+  // Split most profitiable condition.
+  Changed = splitLoop(SplitData[MostProfitableSDIndex]);
+
   if (Changed)
 ++NumIndexSplit;
   
@@ -439,6 +450,25 @@
   return true;
 }
 
+/// Find cost of spliting loop L. Cost is measured in terms of size growth.
+/// Size is growth is calculated based on amount of code duplicated in second
+/// loop.
+unsigned LoopIndexSplit::findSplitCost(Loop *L, SplitInfo &SD) {
+
+  unsigned Cost = 0;
+  BasicBlock *SDBlock = SD.SplitCondition->getParent();
+  for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
+   I != E; ++I) {
+BasicBlock *BB = *I;
+// If a block is not dominated by split condition block then
+// it must be duplicated in both loops.
+if (!DT->dominates(SDBlock, BB))
+  Cost += BB->size();
+  }
+
+  return Cost;
+}
+
 bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
   // FIXME :)
   return false;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40953 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 17:26:03 2007
New Revision: 40953

URL: http://llvm.org/viewvc/llvm-project?rev=40953&view=rev
Log:
Add more comments to memdep.

Modified:
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=40953&r1=40952&r2=40953&view=diff

==
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Aug  8 17:26:03 
2007
@@ -41,7 +41,8 @@
   AU.addRequiredTransitive();
 }
 
-// Find the dependency of a CallSite
+/// getCallSiteDependency - Private helper for finding the local dependencies
+/// of a call site.
 const Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
Instruction* start,
 BasicBlock* block) 
{
@@ -51,14 +52,17 @@
   BasicBlock::iterator blockBegin = C.getInstruction()->getParent()->begin();
   BasicBlock::iterator QI = C.getInstruction();
   
+  // If the starting point was specifiy, use it
   if (start) {
 QI = start;
 blockBegin = start->getParent()->end();
+  // If the starting point wasn't specified, but the block was, use it
   } else if (!start && block) {
 QI = block->end();
 blockBegin = block->end();
   }
   
+  // Walk backwards through the block, looking for dependencies
   while (QI != blockBegin) {
 --QI;
 
@@ -117,21 +121,29 @@
   return NonLocal;
 }
 
+/// nonLocalHelper - Private helper used to calculate non-local dependencies
+/// by doing DFS on the predecessors of a block to find its dependencies
 void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
   BasicBlock* block,
  DenseMap& resp) {
+  // Set of blocks that we've already visited in our DFS
   SmallPtrSet visited;
+  // Current stack of the DFS
   SmallVector stack;
   stack.push_back(block);
   
+  // Do a basic DFS
   while (!stack.empty()) {
 BasicBlock* BB = stack.back();
 
+// If we've already visited this block, no need to revist
 if (visited.count(BB)) {
   stack.pop_back();
   continue;
 }
 
+// If we find a new block with a local dependency for query,
+// then we insert the new dependency and backtrack.
 if (BB != block) {
   visited.insert(BB);
   
@@ -142,6 +154,9 @@
 
 continue;
   }
+// If we re-encounter the starting block, we still need to search it
+// because there might be a dependency in the starting block AFTER
+// the position of the query.  This is necessary to get loops right.
 } else if (BB == block && stack.size() > 1) {
   visited.insert(BB);
   
@@ -154,6 +169,7 @@
   continue;
 }
 
+// If we didn't find anything, recurse on the precessors of this block
 bool predOnStack = false;
 bool inserted = false;
 for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB);
@@ -164,10 +180,16 @@
   } else
 predOnStack = true;
 
+// If we inserted a new predecessor, then we'll come back to this block
 if (inserted)
   continue;
+// If we didn't insert because we have no predecessors, then this
+// query has no dependency at all.
 else if (!inserted && !predOnStack) {
   resp.insert(std::make_pair(BB, const_cast(None)));
+// If we didn't insert because our predecessors are already on the stack,
+// then we might still have a dependency, but it will be discovered during
+// backtracking.
 } else if (!inserted && predOnStack){
   resp.insert(std::make_pair(BB, const_cast(NonLocal)));
 }
@@ -181,6 +203,7 @@
 /// blocks between the query and its dependencies.
 void MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query,
  DenseMap& resp) {
+  // First check that we don't actually have a local dependency.
   const Instruction* localDep = getDependency(query);
   if (localDep != NonLocal) {
 resp.insert(std::make_pair(query->getParent(),
@@ -188,6 +211,7 @@
 return;
   }
   
+  // If not, go ahead and search for non-local ones.
   nonLocalHelper(query, query->getParent(), resp);
 }
 
@@ -247,6 +271,7 @@
   BasicBlock::iterator blockBegin = block ? block->begin()
   : query->getParent()->begin();
   
+  // Walk backwards through the basic block, looking for dependencies
   while (QI != blockBegin) {
 --QI;
 
@@ -350,6 +375,7 @@
 
 /// removeInstruction - Remove an instruction from the dependence analysis,
 /// updating the dependence of instructions that previously depended on it.
+/// This method attempts to keep the cache cohe

[llvm-commits] [llvm] r40955 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

2007-08-08 Thread Scott Michel
Author: pingbak
Date: Wed Aug  8 18:23:31 2007
New Revision: 40955

URL: http://llvm.org/viewvc/llvm-project?rev=40955&view=rev
Log:
If a target really needs to custom lower constants, it should be allowed
to do so.

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=40955&r1=40954&r2=40955&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Aug  8 18:23:31 2007
@@ -965,13 +965,21 @@
 }
 break;
 
-  case ISD::Constant:
+  case ISD::Constant: {
+ConstantSDNode *CN = cast(Node);
+unsigned opAction =
+  TLI.getOperationAction(ISD::Constant, CN->getValueType(0));
+
 // We know we don't need to expand constants here, constants only have one
 // value and we check that it is fine above.
 
-// FIXME: Maybe we should handle things like targets that don't support 
full
-// 32-bit immediates?
+if (opAction == TargetLowering::Custom) {
+  Tmp1 = TLI.LowerOperation(Result, DAG);
+  if (Tmp1.Val)
+Result = Tmp1;
+}
 break;
+  }
   case ISD::ConstantFP: {
 // Spill FP immediates to the constant pool if the target cannot directly
 // codegen them.  Targets often have some immediate values that can be


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40957 - /llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td

2007-08-08 Thread Dale Johannesen
Author: johannes
Date: Wed Aug  8 19:49:19 2007
New Revision: 40957

URL: http://llvm.org/viewvc/llvm-project?rev=40957&view=rev
Log:
Fix arguments for some Altivec instructions.  From SWB.


Modified:
llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td

Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td?rev=40957&r1=40956&r2=40957&view=diff

==
--- llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrAltivec.td Wed Aug  8 19:49:19 2007
@@ -163,12 +163,18 @@
 def IMPLICIT_DEF_VRRC : Pseudo<(outs VRRC:$rD), (ins),"; IMPLICIT_DEF_VRRC 
$rD",
[(set VRRC:$rD, (v4i32 (undef)))]>;
 
-def DSS   : DSS_Form<822, (outs), (ins u5imm:$A, 
u5imm:$STRM,u5imm:$ZERO1,u5imm:$ZERO2),
- "dss $STRM, $A", LdStGeneral /*FIXME*/, []>;
-def DST   : DSS_Form<342, (outs), (ins u5imm:$T, u5imm:$STRM, GPRC:$rA, 
GPRC:$rB),
- "dst $rA, $rB, $STRM, $T", LdStGeneral /*FIXME*/, []>;
-def DSTST : DSS_Form<374, (outs), (ins u5imm:$T, u5imm:$STRM, GPRC:$rA, 
GPRC:$rB),
-   "dstst $rA, $rB, $STRM, $T", LdStGeneral /*FIXME*/, []>;
+def DSS   : DSS_Form<822, (outs), (ins u5imm:$ZERO0, 
u5imm:$STRM,u5imm:$ZERO1,u5imm:$ZERO2),
+ "dss $STRM", LdStGeneral /*FIXME*/, []>;
+def DSSALL: DSS_Form<822, (outs), (ins u5imm:$ONE, 
u5imm:$ZERO0,u5imm:$ZERO1,u5imm:$ZERO2),
+ "dssall", LdStGeneral /*FIXME*/, []>;
+def DST   : DSS_Form<342, (outs), (ins u5imm:$ZERO, u5imm:$STRM, GPRC:$rA, 
GPRC:$rB),
+ "dst $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
+def DSTT  : DSS_Form<342, (outs), (ins u5imm:$ONE, u5imm:$STRM, GPRC:$rA, 
GPRC:$rB),
+ "dstt $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
+def DSTST : DSS_Form<374, (outs), (ins u5imm:$ZERO, u5imm:$STRM, GPRC:$rA, 
GPRC:$rB),
+   "dstst $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
+def DSTSTT: DSS_Form<374, (outs), (ins u5imm:$ONE, u5imm:$STRM, GPRC:$rA, 
GPRC:$rB),
+   "dststt $rA, $rB, $STRM", LdStGeneral /*FIXME*/, []>;
 
 def MFVSCR : VXForm_4<1540, (outs VRRC:$vD), (ins),
   "mfvscr $vD", LdStGeneral,
@@ -532,15 +538,15 @@
 
 // DS* intrinsics.
 def : Pat<(int_ppc_altivec_dss imm:$STRM), (DSS 0, imm:$STRM, 0, 0)>;
-def : Pat<(int_ppc_altivec_dssall), (DSS 1, 0, 0, 0)>;
+def : Pat<(int_ppc_altivec_dssall), (DSSALL 1, 0, 0, 0)>;
 def : Pat<(int_ppc_altivec_dst GPRC:$rA, GPRC:$rB, imm:$STRM),
   (DST 0, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
 def : Pat<(int_ppc_altivec_dstt GPRC:$rA, GPRC:$rB, imm:$STRM),
-  (DST 1, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
+  (DSTT 1, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
 def : Pat<(int_ppc_altivec_dstst GPRC:$rA, GPRC:$rB, imm:$STRM),
   (DSTST 0, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
 def : Pat<(int_ppc_altivec_dststt GPRC:$rA, GPRC:$rB, imm:$STRM),
-  (DSTST 1, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
+  (DSTSTT 1, imm:$STRM, GPRC:$rA, GPRC:$rB)>;
 
 // Undef.
 def : Pat<(v16i8 (undef)), (IMPLICIT_DEF_VRRC)>;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40958 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/Target/X86/X86ISelLowering.

2007-08-08 Thread Dale Johannesen
Author: johannes
Date: Wed Aug  8 20:04:01 2007
New Revision: 40958

URL: http://llvm.org/viewvc/llvm-project?rev=40958&view=rev
Log:
long double 9 of N.  This finishes up the X86-32 bits
(constants are still not handled).  Adds ConvertActions
to control fp-to-fp conversions (these are currently
defaulted for all other targets, so no changes there).

Modified:
llvm/trunk/include/llvm/Target/TargetLowering.h
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=40958&r1=40957&r2=40958&view=diff

==
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Aug  8 20:04:01 2007
@@ -327,6 +327,24 @@
getIndexedStoreAction(IdxMode, VT) == Custom;
   }
   
+  /// getConvertAction - Return how the conversion should be treated:
+  /// either it is legal, needs to be promoted to a larger size, needs to be
+  /// expanded to some other code sequence, or the target has a custom expander
+  /// for it.
+  LegalizeAction
+  getConvertAction(MVT::ValueType FromVT, MVT::ValueType ToVT) const {
+if (MVT::isExtendedVT(ToVT) || MVT::isExtendedVT(FromVT))
+  return Expand;
+return (LegalizeAction)((ConvertActions[FromVT] >> (2*ToVT)) & 3);
+  }
+
+  /// isConvertLegal - Return true if the specified conversion is legal
+  /// on this target.
+  bool isConvertLegal(MVT::ValueType FromVT, MVT::ValueType ToVT) const {
+return getConvertAction(FromVT, ToVT) == Legal ||
+   getConvertAction(FromVT, ToVT) == Custom;
+  }
+
   /// getTypeToPromoteTo - If the action for this operation is to promote, this
   /// method returns the ValueType to promote to.
   MVT::ValueType getTypeToPromoteTo(unsigned Op, MVT::ValueType VT) const {
@@ -742,6 +760,16 @@
 IndexedModeActions[1][IdxMode] |= (uint64_t)Action << VT*2;
   }
   
+  /// setConvertAction - Indicate that the specified conversion does or does
+  /// not work with the with specified type and indicate what to do about it.
+  void setConvertAction(MVT::ValueType FromVT, MVT::ValueType ToVT, 
+LegalizeAction Action) {
+assert(FromVT < MVT::LAST_VALUETYPE && ToVT < 32 && 
+   "Table isn't big enough!");
+ConvertActions[FromVT] &= ~(uint64_t(3UL) << ToVT*2);
+ConvertActions[FromVT] |= (uint64_t)Action << ToVT*2;
+  }
+
   /// AddPromotedToType - If Opc/OrigVT is specified as being promoted, the
   /// promotion code defaults to trying a larger integer/fp until it can find
   /// one that works.  If that default is insufficient, this method can be used
@@ -1081,6 +1109,13 @@
   /// deal with the load / store.
   uint64_t IndexedModeActions[2][ISD::LAST_INDEXED_MODE];
   
+  /// ConvertActions - For each conversion from source type to destination 
type,
+  /// keep a LegalizeAction that indicates how instruction selection should
+  /// deal with the conversion.
+  /// Currently, this is used only for floating->floating conversions
+  /// (FP_EXTEND and FP_ROUND).
+  uint64_t ConvertActions[MVT::LAST_VALUETYPE];
+
   ValueTypeActionImpl ValueTypeActions;
 
   std::vector LegalFPImmediates;

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=40958&r1=40957&r2=40958&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Aug  8 20:04:01 2007
@@ -3194,33 +3194,58 @@
 }
 break;
 
-  case ISD::FP_ROUND:
-if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) == 
-TargetLowering::Expand) {
-  // The only way we can lower this is to turn it into a TRUNCSTORE,
-  // EXTLOAD pair, targetting a temporary location (a stack slot).
-
-  // NOTE: there is a choice here between constantly creating new stack
-  // slots and always reusing the same one.  We currently always create
-  // new ones, as reuse may inhibit scheduling.
-  MVT::ValueType VT = Op.getValueType();// 32
-  const Type *Ty = MVT::getTypeForValueType(VT);
-  uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
-  unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
-  MachineFunction &MF = DAG.getMachineFunction();
-  int SSFI =
-MF.getFrameInfo()->CreateStackObject(TySize, Align);
-  SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
-  Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0),
- StackSlot, NULL, 0, VT);
-

[llvm-commits] [llvm] r40960 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

2007-08-08 Thread Devang Patel
Author: dpatel
Date: Wed Aug  8 20:39:01 2007
New Revision: 40960

URL: http://llvm.org/viewvc/llvm-project?rev=40960&view=rev
Log:
Traverse loop blocks' terminators to find split candidates.

Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=40960&r1=40959&r2=40960&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Aug  8 20:39:01 2007
@@ -54,7 +54,9 @@
 class SplitInfo {
 public:
   SplitInfo() : IndVar(NULL), SplitValue(NULL), ExitValue(NULL),
-SplitCondition(NULL), ExitCondition(NULL) {}
+SplitCondition(NULL), ExitCondition(NULL), 
+IndVarIncrement(NULL) {}
+
   // Induction variable whose range is being split by this transformation.
   PHINode *IndVar;
   
@@ -70,6 +72,8 @@
   // Loop exit condition.
   ICmpInst *ExitCondition;
 
+  Instruction *IndVarIncrement;
+
   // Clear split info.
   void clear() {
 IndVar = NULL;
@@ -77,7 +81,12 @@
 ExitValue = NULL;
 SplitCondition = NULL;
 ExitCondition = NULL;
+IndVarIncrement = NULL;
   }
+
+  /// Return true if V is a induction variable or induction variable's
+  /// increment for loop L.
+  bool findIndVar(Value *V, Loop *L);
 };
 
   private:
@@ -172,52 +181,93 @@
   return Changed;
 }
 
+/// Return true if V is a induction variable or induction variable's
+/// increment for loop L.
+bool LoopIndexSplit::SplitInfo::findIndVar(Value *V, Loop *L) {
+  
+  Instruction *I = dyn_cast(V);
+  if (!I)
+return false;
+
+  // Check if I is a phi node from loop header or not.
+  if (PHINode *PN = dyn_cast(V)) {
+if (PN->getParent() == L->getHeader()) {
+IndVar = PN;
+return true;
+}
+  }
+ 
+  // Check if I is a add instruction whose one operand is
+  // phi node from loop header and second operand is constant.
+  if (I->getOpcode() != Instruction::Add)
+return false;
+  
+  Value *Op0 = I->getOperand(0);
+  Value *Op1 = I->getOperand(1);
+  
+  if (PHINode *PN = dyn_cast(Op0)) {
+if (PN->getParent() == L->getHeader()
+&& isa(Op1)) {
+  IndVar = PN;
+  IndVarIncrement = I;
+  return true;
+}
+  }
+  
+  if (PHINode *PN = dyn_cast(Op1)) {
+if (PN->getParent() == L->getHeader()
+&& isa(Op0)) {
+  IndVar = PN;
+  IndVarIncrement = I;
+  return true;
+}
+  }
+  
+  return false;
+}
+
 /// Find condition inside a loop that is suitable candidate for index split.
 void LoopIndexSplit::findSplitCondition() {
 
   SplitInfo SD;
-  BasicBlock *Header = L->getHeader();
+  // Check all basic block's terminators.
 
-  for (BasicBlock::iterator I = Header->begin(); isa(I); ++I) {
-PHINode *PN = cast(I);
+  for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
+   I != E; ++I) {
+BasicBlock *BB = *I;
 
-if (!PN->getType()->isInteger())
+// If this basic block does not terminate in a conditional branch
+// then terminator is not a suitable split condition.
+BranchInst *BR = dyn_cast(BB->getTerminator());
+if (!BR)
   continue;
-
-SCEVHandle SCEV = SE->getSCEV(PN);
-if (!isa(SCEV)) 
+
+if (BR->isUnconditional())
   continue;
 
-// If this phi node is used in a compare instruction then it is a
-// split condition candidate.
-for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end(); 
- UI != E; ++UI) {
-  if (ICmpInst *CI = dyn_cast(*UI)) {
-SD.SplitCondition = CI;
-break;
-  }
-}
-
-// Valid SplitCondition's one operand is phi node and the other operand
-// is loop invariant.
-if (SD.SplitCondition) {
-  if (SD.SplitCondition->getOperand(0) != PN)
-SD.SplitValue = SD.SplitCondition->getOperand(0);
-  else
-SD.SplitValue = SD.SplitCondition->getOperand(1);
-  SCEVHandle ValueSCEV = SE->getSCEV(SD.SplitValue);
-
-  // If SplitValue is not invariant then SplitCondition is not appropriate.
-  if (!ValueSCEV->isLoopInvariant(L))
-SD.SplitCondition = NULL;
+ICmpInst *CI = dyn_cast(BR->getCondition());
+if (!CI)
+  return;
+
+// If one operand is loop invariant and second operand is SCEVAddRecExpr
+// based on induction variable then CI is a candidate split condition.
+Value *V0 = CI->getOperand(0);
+Value *V1 = CI->getOperand(1);
+
+SCEVHandle SH0 = SE->getSCEV(V0);
+SCEVHandle SH1 = SE->getSCEV(V1);
+
+if (SH0->isLoopInvariant(L) && isa(SH1)) {
+  SD.SplitValue = V0;
+  SD.SplitCondition = CI;
+  if (SD.findIndVar(V1, L))
+SplitData.push_back(SD);
 }
-
-

Re: [llvm-commits] [llvm] r40946 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/DeadStoreElimination.cpp lib/Transfo

2007-08-08 Thread Chris Lattner
> URL: http://llvm.org/viewvc/llvm-project?rev=40946&view=rev
> Log:
> Change the None and NonLocal markers in memdep to be const.

Sorry for the confusion but:

> -static Instruction* NonLocal;
> -static Instruction* None;
> +static const Instruction* NonLocal;
> +static const Instruction* None;

This (and all the changes to change Instruction* -> const  
Instruction*) doesn't make NonLocal and None const.  You want:

 static Instruction* const NonLocal;
 static Instruction* const None;

Which doesn't require the const_cast's and other things.

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r40961 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/DeadStoreElimination.cpp lib/Transforms/

2007-08-08 Thread Owen Anderson
Author: resistor
Date: Wed Aug  8 23:42:44 2007
New Revision: 40961

URL: http://llvm.org/viewvc/llvm-project?rev=40961&view=rev
Log:
Make NonLocal and None const in the right way. :-)

Modified:
llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/lib/Transforms/Scalar/RedundantLoadElimination.cpp

Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=40961&r1=40960&r2=40961&view=diff

==
--- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Wed Aug  8 
23:42:44 2007
@@ -33,23 +33,23 @@
   private:
 // A map from instructions to their dependency, with a boolean
 // flags for whether this mapping is confirmed or not
-typedef DenseMap > 
+typedef DenseMap > 
 depMapType;
 depMapType depGraphLocal;
 
 // A reverse mapping form dependencies to the dependees.  This is
 // used when removing instructions to keep the cache coherent.
-typedef DenseMap >
+typedef DenseMap >
 reverseDepMapType;
 reverseDepMapType reverseDep;
 
   public:
 // Special marker indicating that the query has no dependency
 // in the specified block.
-static const Instruction* NonLocal;
+static Instruction* const NonLocal;
 
 // Special marker indicating that the query has no dependency at all
-static const Instruction* None;
+static Instruction* const None;
 
 static char ID; // Class identification, replacement for typeinfo
 MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
@@ -71,7 +71,7 @@
 
 /// getDependency - Return the instruction on which a memory operation
 /// depends, starting with start.
-const Instruction* getDependency(Instruction* query, Instruction* start = 
0,
+Instruction* getDependency(Instruction* query, Instruction* start = 0,
BasicBlock* block = 0);
 
 /// getNonLocalDependency - Fills the passed-in map with the non-local 
@@ -85,7 +85,7 @@
 void removeInstruction(Instruction* rem);
 
   private:
-const Instruction* getCallSiteDependency(CallSite C, Instruction* start,
+Instruction* getCallSiteDependency(CallSite C, Instruction* start,
BasicBlock* block);
 void nonLocalHelper(Instruction* query, BasicBlock* block,
 DenseMap& resp);

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=40961&r1=40960&r2=40961&view=diff

==
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Aug  8 23:42:44 
2007
@@ -26,8 +26,8 @@
 
 char MemoryDependenceAnalysis::ID = 0;
   
-const Instruction* MemoryDependenceAnalysis::NonLocal = (Instruction*)-3;
-const Instruction* MemoryDependenceAnalysis::None = (Instruction*)-4;
+Instruction* const MemoryDependenceAnalysis::NonLocal = (Instruction*)-3;
+Instruction* const MemoryDependenceAnalysis::None = (Instruction*)-4;
   
 // Register this pass...
 static RegisterPass X("memdep",
@@ -43,7 +43,7 @@
 
 /// getCallSiteDependency - Private helper for finding the local dependencies
 /// of a call site.
-const Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
+Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C,
Instruction* start,
 BasicBlock* block) 
{
   
@@ -147,9 +147,9 @@
 if (BB != block) {
   visited.insert(BB);
   
-  const Instruction* localDep = getDependency(query, 0, BB);
+  Instruction* localDep = getDependency(query, 0, BB);
   if (localDep != NonLocal) {
-resp.insert(std::make_pair(BB, const_cast(localDep)));
+resp.insert(std::make_pair(BB, localDep));
 stack.pop_back();
 
 continue;
@@ -160,9 +160,9 @@
 } else if (BB == block && stack.size() > 1) {
   visited.insert(BB);
   
-  const Instruction* localDep = getDependency(query, 0, BB);
+  Instruction* localDep = getDependency(query, 0, BB);
   if (localDep != query)
-resp.insert(std::make_pair(BB, const_cast(localDep)));
+resp.insert(std::make_pair(BB, localDep));
   
   stack.pop_back();
   
@@ -186,12 +186,12 @@
 // If we didn't insert because we have no predecessors, 

Re: [llvm-commits] [llvm] r40961 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/DeadStoreElimination.cpp lib/Transfo

2007-08-08 Thread Chris Lattner
> URL: http://llvm.org/viewvc/llvm-project?rev=40961&view=rev
> Log:
> Make NonLocal and None const in the right way. :-)

Thanks Owen :)

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits