Re: [llvm-commits] llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp

2007-03-04 Thread Chris Lattner

On Mar 3, 2007, at 6:30 AM, Nicolas Geoffray wrote:

> Chris Lattner wrote:
>>
>>> Because R31 is not used as a callee saved register when  
>>> llvm::NoFramePointerElim is set to 1.
>>
>> NoFramePointerElim doesn't change the ABI, only the codegen model.
>
> Yes it doesn't change the ABI, but R31's offset in Linux/ELF is in  
> the callee saved area. In Macho it is not.

Ok, so it's not related to NoFramePointerElim?  If that's the case,  
you should just have Macho and ELF return different sets of callee  
saved regs.

>>> The algorithm
>>> that calculates the callee saved registers' addresses does not  
>>> save R31's offset when used as a frame pointer.
>>> And with the ELF Abi, R31's offset is in the callee saved  
>>> registers area. Therefore I have to force its allocation
>>> (at the -4 offset).
>>
>> Please see how the LR register forces spilling to a specific stack  
>> slot.
>>
>
> You're talking about this code right?
>  MachineLocation LRDst(MachineLocation::VirtualFP, LROffset);
>  MachineLocation LRSrc(IsPPC64 ? PPC::LR8 : PPC::LR);
>  Moves.push_back(MachineMove(FrameLabelId, LRDst, LRSrc));
>
> However this is not enough for R31 because R31's offset is in the  
> callee saved area. And if I don't add the code of this patch,
> the algorithm that calculates callee saved addresses does not take  
> into account the fact that R31 is in the callee saved area.

Hrm, the PPC backend changed.  It should override the  
'getCalleeSavedSpillSlots' hook, to say that LR (and R31) must be  
spilled as specific offsets on the stack.  I don't know how it works  
now.

> Btw, I'm just reproducing the code of  LowerDYNAMIC_STACKALLOC  
> (PPCISelLowering.cpp). As the compilation may not go
> through this method, I have to do the saving of R31's offset before  
> the callee saved scan.

LowerDYNAMIC_STACKALLOC is a bit different, on darwin, it has to  
ensure that the stack pointer/frame pointer are kept in sync as the  
stack is adjusted.  This is a very strange ABI rule, and I'd be  
surprised if ELF did the same thing.

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


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c

2007-03-04 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/SignlessTypes:

ccc.c updated: 1.2 -> 1.3
---
Log message:

Terminate output with newline.


---
Diffs of the changes:  (+1 -1)

 ccc.c |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c
diff -u llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c:1.2 
llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c:1.3
--- llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c:1.2Wed Jan 17 
20:10:04 2007
+++ llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.cSun Mar  4 
13:14:27 2007
@@ -48,7 +48,7 @@
   sh = (short)-1;
   ush = (unsigned short) -1;
 
-  printf("%d %hd %hu", TestVal, sh, ush);
+  printf("%d %hd %hu\n", TestVal, sh, ush);
 
   return TestVal;
 }



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


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.391 -> 1.392
---
Log message:

eliminate some ops if they have an undef RHS


---
Diffs of the changes:  (+2 -0)

 SelectionDAG.cpp |2 ++
 1 files changed, 2 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.391 
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.392
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.391Sun Feb 25 
02:24:27 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp  Sun Mar  4 14:01:46 2007
@@ -1325,6 +1325,8 @@
   if (N2.getOpcode() == ISD::UNDEF) {
 switch (Opcode) {
 case ISD::ADD:
+case ISD::ADDC:
+case ISD::ADDE:
 case ISD::SUB:
 case ISD::FADD:
 case ISD::FSUB:



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


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.271 -> 1.272
---
Log message:

canonicalize constants to the RHS of addc/adde.  If nothing uses the carry out 
of
addc, turn it into add.

This allows us to compile:

long long test(long long A, unsigned B) {
  return (A + ((long long)B << 32)) & 123;
}

into:

_test:
movl $123, %eax
andl 4(%esp), %eax
xorl %edx, %edx
ret

instead of:
_test:
xorl %edx, %edx
movl %edx, %eax
addl 4(%esp), %eax   ;; add of zero
andl $123, %eax
ret



---
Diffs of the changes:  (+47 -0)

 DAGCombiner.cpp |   47 +++
 1 files changed, 47 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.271 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.272
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.271 Sun Feb 25 21:13:59 2007
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp   Sun Mar  4 14:03:15 2007
@@ -205,6 +205,8 @@
 SDOperand visitTokenFactor(SDNode *N);
 SDOperand visitADD(SDNode *N);
 SDOperand visitSUB(SDNode *N);
+SDOperand visitADDC(SDNode *N);
+SDOperand visitADDE(SDNode *N);
 SDOperand visitMUL(SDNode *N);
 SDOperand visitSDIV(SDNode *N);
 SDOperand visitUDIV(SDNode *N);
@@ -502,6 +504,8 @@
   case ISD::TokenFactor:return visitTokenFactor(N);
   case ISD::ADD:return visitADD(N);
   case ISD::SUB:return visitSUB(N);
+  case ISD::ADDC:   return visitADDC(N);
+  case ISD::ADDE:   return visitADDE(N);
   case ISD::MUL:return visitMUL(N);
   case ISD::SDIV:   return visitSDIV(N);
   case ISD::UDIV:   return visitUDIV(N);
@@ -740,6 +744,49 @@
   return SDOperand();
 }
 
+SDOperand DAGCombiner::visitADDC(SDNode *N) {
+  SDOperand N0 = N->getOperand(0);
+  SDOperand N1 = N->getOperand(1);
+  ConstantSDNode *N0C = dyn_cast(N0);
+  ConstantSDNode *N1C = dyn_cast(N1);
+  MVT::ValueType VT = N0.getValueType();
+  
+  // If the flag result is dead, turn this into an ADD.
+  if (N->hasNUsesOfValue(0, 1))
+return CombineTo(N, DAG.getNode(ISD::ADD, VT, N1, N0),
+ SDOperand(N, 1));
+  
+  // canonicalize constant to RHS.
+  if (N0C && !N1C)
+return DAG.getNode(ISD::ADDC, VT, N1, N0);
+  
+  // fold (add x, 0) -> x + no carry out
+  //if (N1C && N1C->isNullValue())
+  //  return N0;
+  
+  return SDOperand();
+}
+
+SDOperand DAGCombiner::visitADDE(SDNode *N) {
+  SDOperand N0 = N->getOperand(0);
+  SDOperand N1 = N->getOperand(1);
+  ConstantSDNode *N0C = dyn_cast(N0);
+  ConstantSDNode *N1C = dyn_cast(N1);
+  MVT::ValueType VT = N0.getValueType();
+  
+  // canonicalize constant to RHS
+  if (N0C && !N1C)
+return DAG.getNode(ISD::ADDE, VT, N1, N0, N->getOperand(2));
+  
+  // fold (add x, 0) -> x
+  //if (N1C && N1C->isNullValue())
+  //  return N0;
+  
+  return SDOperand();
+}
+
+
+
 SDOperand DAGCombiner::visitSUB(SDNode *N) {
   SDOperand N0 = N->getOperand(0);
   SDOperand N1 = N->getOperand(1);



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


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.272 -> 1.273
---
Log message:

generalize


---
Diffs of the changes:  (+9 -5)

 DAGCombiner.cpp |   14 +-
 1 files changed, 9 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.272 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.273
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.272 Sun Mar  4 14:03:15 2007
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp   Sun Mar  4 14:08:45 2007
@@ -757,8 +757,10 @@
  SDOperand(N, 1));
   
   // canonicalize constant to RHS.
-  if (N0C && !N1C)
-return DAG.getNode(ISD::ADDC, VT, N1, N0);
+  if (N0C && !N1C) {
+SDOperand Ops[] = { N1, N0 };
+return DAG.getNode(ISD::ADDC, N->getVTList(), Ops, 2);
+  }
   
   // fold (add x, 0) -> x + no carry out
   //if (N1C && N1C->isNullValue())
@@ -772,11 +774,13 @@
   SDOperand N1 = N->getOperand(1);
   ConstantSDNode *N0C = dyn_cast(N0);
   ConstantSDNode *N1C = dyn_cast(N1);
-  MVT::ValueType VT = N0.getValueType();
+  //MVT::ValueType VT = N0.getValueType();
   
   // canonicalize constant to RHS
-  if (N0C && !N1C)
-return DAG.getNode(ISD::ADDE, VT, N1, N0, N->getOperand(2));
+  if (N0C && !N1C) {
+SDOperand Ops[] = { N1, N0, N->getOperand(2) };
+return DAG.getNode(ISD::ADDE, N->getVTList(), Ops, 3);
+  }
   
   // fold (add x, 0) -> x
   //if (N1C && N1C->isNullValue())



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


[llvm-commits] CVS: llvm/test/CodeGen/Generic/addc-fold2.ll

2007-03-04 Thread Chris Lattner


Changes in directory llvm/test/CodeGen/Generic:

addc-fold2.ll added (r1.1)
---
Log message:

new testcase, corresponds to:

long long test(long long A, unsigned B) {
  return (A + ((long long)B << 32));
}



---
Diffs of the changes:  (+11 -0)

 addc-fold2.ll |   11 +++
 1 files changed, 11 insertions(+)


Index: llvm/test/CodeGen/Generic/addc-fold2.ll
diff -c /dev/null llvm/test/CodeGen/Generic/addc-fold2.ll:1.1
*** /dev/null   Sun Mar  4 14:39:57 2007
--- llvm/test/CodeGen/Generic/addc-fold2.ll Sun Mar  4 14:39:47 2007
***
*** 0 
--- 1,11 
+ ; RUN: llvm-as < %s | llc &&
+ ; RUN: llvm-as < %s | llc -march=x86 | grep 'add' &&
+ ; RUN: llvm-as < %s | llc -march=x86 | not grep 'adc'
+ 
+ define i64 @test(i64 %A, i32 %B) {
+ %tmp12 = zext i32 %B to i64 ;  [#uses=1]
+ %tmp3 = shl i64 %tmp12, 32  ;  [#uses=1]
+ %tmp5 = add i64 %tmp3, %A   ;  [#uses=1]
+ ret i64 %tmp5
+ }
+ 



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


[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h

2007-03-04 Thread Chris Lattner


Changes in directory llvm/include/llvm/CodeGen:

SelectionDAGNodes.h updated: 1.178 -> 1.179
---
Log message:

add a new node


---
Diffs of the changes:  (+4 -0)

 SelectionDAGNodes.h |4 
 1 files changed, 4 insertions(+)


Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.178 
llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.179
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.178 Wed Feb 21 16:37:22 2007
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h   Sun Mar  4 14:40:06 2007
@@ -192,6 +192,10 @@
 // Simple integer binary arithmetic operators.
 ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
 
+// CARRY_FALSE - This node is used when folding other nodes,
+// like ADDC/SUBC, which indicate the carry result is always false.
+CARRY_FALSE,
+
 // Carry-setting nodes for multiple precision addition and subtraction.
 // These nodes take two operands of the same value type, and produce two
 // results.  The first result is the normal add or sub result, the second



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


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp SelectionDAG.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

DAGCombiner.cpp updated: 1.273 -> 1.274
SelectionDAG.cpp updated: 1.392 -> 1.393
---
Log message:

fold away addc nodes when we know there cannot be a carry-out.


---
Diffs of the changes:  (+28 -8)

 DAGCombiner.cpp  |   35 +++
 SelectionDAG.cpp |1 +
 2 files changed, 28 insertions(+), 8 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.273 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.274
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.273 Sun Mar  4 14:08:45 2007
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp   Sun Mar  4 14:40:38 2007
@@ -754,7 +754,7 @@
   // If the flag result is dead, turn this into an ADD.
   if (N->hasNUsesOfValue(0, 1))
 return CombineTo(N, DAG.getNode(ISD::ADD, VT, N1, N0),
- SDOperand(N, 1));
+ DAG.getNode(ISD::CARRY_FALSE, MVT::Flag));
   
   // canonicalize constant to RHS.
   if (N0C && !N1C) {
@@ -762,9 +762,25 @@
 return DAG.getNode(ISD::ADDC, N->getVTList(), Ops, 2);
   }
   
-  // fold (add x, 0) -> x + no carry out
-  //if (N1C && N1C->isNullValue())
-  //  return N0;
+  // fold (addc x, 0) -> x + no carry out
+  if (N1C && N1C->isNullValue())
+return CombineTo(N, N0, DAG.getNode(ISD::CARRY_FALSE, MVT::Flag));
+  
+  // fold (addc a, b) -> (or a, b), CARRY_FALSE iff a and b share no bits.
+  uint64_t LHSZero, LHSOne;
+  uint64_t RHSZero, RHSOne;
+  uint64_t Mask = MVT::getIntVTBitMask(VT);
+  TLI.ComputeMaskedBits(N0, Mask, LHSZero, LHSOne);
+  if (LHSZero) {
+TLI.ComputeMaskedBits(N1, Mask, RHSZero, RHSOne);
+
+// If all possibly-set bits on the LHS are clear on the RHS, return an OR.
+// If all possibly-set bits on the RHS are clear on the LHS, return an OR.
+if ((RHSZero & (~LHSZero & Mask)) == (~LHSZero & Mask) ||
+(LHSZero & (~RHSZero & Mask)) == (~RHSZero & Mask))
+  return CombineTo(N, DAG.getNode(ISD::OR, VT, N0, N1),
+   DAG.getNode(ISD::CARRY_FALSE, MVT::Flag));
+  }
   
   return SDOperand();
 }
@@ -772,19 +788,22 @@
 SDOperand DAGCombiner::visitADDE(SDNode *N) {
   SDOperand N0 = N->getOperand(0);
   SDOperand N1 = N->getOperand(1);
+  SDOperand CarryIn = N->getOperand(2);
   ConstantSDNode *N0C = dyn_cast(N0);
   ConstantSDNode *N1C = dyn_cast(N1);
   //MVT::ValueType VT = N0.getValueType();
   
   // canonicalize constant to RHS
   if (N0C && !N1C) {
-SDOperand Ops[] = { N1, N0, N->getOperand(2) };
+SDOperand Ops[] = { N1, N0, CarryIn };
 return DAG.getNode(ISD::ADDE, N->getVTList(), Ops, 3);
   }
   
-  // fold (add x, 0) -> x
-  //if (N1C && N1C->isNullValue())
-  //  return N0;
+  // fold (adde x, y, false) -> (addc x, y)
+  if (CarryIn.getOpcode() == ISD::CARRY_FALSE) {
+SDOperand Ops[] = { N1, N0 };
+return DAG.getNode(ISD::ADDC, N->getVTList(), Ops, 2);
+  }
   
   return SDOperand();
 }


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.392 
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.393
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.392Sun Mar  4 
14:01:46 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp  Sun Mar  4 14:40:38 2007
@@ -2774,6 +2774,7 @@
   case ISD::VECTOR_SHUFFLE:  return "vector_shuffle";
   case ISD::VVECTOR_SHUFFLE: return "vvector_shuffle";
   case ISD::VBIT_CONVERT:return "vbit_convert";
+  case ISD::CARRY_FALSE: return "carry_false";
   case ISD::ADDC:return "addc";
   case ISD::ADDE:return "adde";
   case ISD::SUBC:return "subc";



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


[llvm-commits] Updated LowerSwitch pass

2007-03-04 Thread Anton Korobeynikov
Hello, Everyone.

This is updated LowerSwitch patch. I've also attached examples - before
& after. I'll add testcase soon after commit.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.

diff -r d294d12d3530 lib/Transforms/Utils/LowerSwitch.cpp
--- a/lib/Transforms/Utils/LowerSwitch.cpp	Sun Mar 04 06:36:24 2007 +
+++ b/lib/Transforms/Utils/LowerSwitch.cpp	Sun Mar 04 23:24:14 2007 +0300
@@ -40,26 +40,38 @@ namespace {
   AU.addPreservedID(LowerInvokePassID);
   AU.addPreservedID(LowerAllocationsID);
 }
-
-typedef std::pair Case;
-typedef std::vector::iterator   CaseItr;
+
+struct CaseRange {
+  Constant* Low;
+  Constant* High;
+  BasicBlock* BB;
+
+  CaseRange(Constant* _Low = NULL, Constant* _High = NULL,
+BasicBlock* _BB = NULL):
+Low(_Low), High(_High), BB(_BB) { }
+};
+
+typedef std::vector   CaseVector;
+typedef std::vector::iterator CaseItr;
   private:
 void processSwitchInst(SwitchInst *SI);
 
 BasicBlock* switchConvert(CaseItr Begin, CaseItr End, Value* Val,
   BasicBlock* OrigBlock, BasicBlock* Default);
-BasicBlock* newLeafBlock(Case& Leaf, Value* Val,
+BasicBlock* newLeafBlock(CaseRange& Leaf, Value* Val,
  BasicBlock* OrigBlock, BasicBlock* Default);
+unsigned Clusterify(CaseVector& Cases, SwitchInst *SI);
   };
 
   /// The comparison function for sorting the switch case values in the vector.
+  /// WARNING: Case ranges should be disjoint!
   struct CaseCmp {
-bool operator () (const LowerSwitch::Case& C1,
-  const LowerSwitch::Case& C2) {
-
-  const ConstantInt* CI1 = cast(C1.first);
-  const ConstantInt* CI2 = cast(C2.first);
-  return CI1->getValue().ult(CI2->getValue());
+bool operator () (const LowerSwitch::CaseRange& C1,
+  const LowerSwitch::CaseRange& C2) {
+
+  const ConstantInt* CI1 = cast(C1.Low);
+  const ConstantInt* CI2 = cast(C2.High);
+  return CI1->getValue().slt(CI2->getValue());
 }
   };
 
@@ -91,19 +103,20 @@ bool LowerSwitch::runOnFunction(Function
 
 // operator<< - Used for debugging purposes.
 //
-std::ostream& operator<<(std::ostream &O,
- const std::vector &C) {
+static std::ostream& operator<<(std::ostream &O,
+const LowerSwitch::CaseVector &C) {
   O << "[";
 
-  for (std::vector::const_iterator B = C.begin(),
+  for (LowerSwitch::CaseVector::const_iterator B = C.begin(),
  E = C.end(); B != E; ) {
-O << *B->first;
+O << *B->Low << " -" << *B->High;
 if (++B != E) O << ", ";
   }
 
   return O << "]";
 }
-OStream& operator<<(OStream &O, const std::vector &C) {
+
+static OStream& operator<<(OStream &O, const LowerSwitch::CaseVector &C) {
   if (O.stream()) *O.stream() << C;
   return O;
 }
@@ -121,14 +134,16 @@ BasicBlock* LowerSwitch::switchConvert(C
 return newLeafBlock(*Begin, Val, OrigBlock, Default);
 
   unsigned Mid = Size / 2;
-  std::vector LHS(Begin, Begin + Mid);
+  std::vector LHS(Begin, Begin + Mid);
   DOUT << "LHS: " << LHS << "\n";
-  std::vector RHS(Begin + Mid, End);
+  std::vector RHS(Begin + Mid, End);
   DOUT << "RHS: " << RHS << "\n";
 
-  Case& Pivot = *(Begin + Mid);
+  CaseRange& Pivot = *(Begin + Mid);
   DEBUG( DOUT << "Pivot ==> " 
-  << cast(Pivot.first)->getValue().toStringSigned(10) 
+  << cast(Pivot.Low)->getValue().toStringSigned(10)
+  << " -"
+  << cast(Pivot.High)->getValue().toStringSigned(10)
   << "\n");
 
   BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
@@ -142,7 +157,7 @@ BasicBlock* LowerSwitch::switchConvert(C
   BasicBlock* NewNode = new BasicBlock("NodeBlock");
   F->getBasicBlockList().insert(OrigBlock->getNext(), NewNode);
 
-  ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_ULT, Val, Pivot.first, "Pivot");
+  ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_SLT, Val, Pivot.Low, "Pivot");
   NewNode->getInstList().push_back(Comp);
   new BranchInst(LBranch, RBranch, Comp, NewNode);
   return NewNode;
@@ -154,7 +169,7 @@ BasicBlock* LowerSwitch::switchConvert(C
 // can't be another valid case value, so the jump to the "default" branch
 // is warranted.
 //
-BasicBlock* LowerSwitch::newLeafBlock(Case& Leaf, Value* Val,
+BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val,
   BasicBlock* OrigBlock,
   BasicBlock* Default)
 {
@@ -162,25 +177,92 @@ BasicBlock* LowerSwitch::newLeafBlock(Ca
   BasicBlock* NewLeaf = new BasicBlock("LeafBlock");
   F->getBasicBlockList().insert(OrigBlock->getNext(), NewLeaf);
 
-  // Make the seteq instruction...
-  ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_EQ, Val,
-Leaf.first, "SwitchLeaf");
-  NewLeaf->getInstLis

[llvm-commits] CVS: llvm-www/developers.txt

2007-03-04 Thread Jim Laskey


Changes in directory llvm-www:

developers.txt updated: 1.9 -> 1.10
---
Log message:

Upadte e-mail address.

---
Diffs of the changes:  (+1 -1)

 developers.txt |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm-www/developers.txt
diff -u llvm-www/developers.txt:1.9 llvm-www/developers.txt:1.10
--- llvm-www/developers.txt:1.9 Thu Aug 17 11:29:55 2006
+++ llvm-www/developers.txt Sun Mar  4 15:09:17 2007
@@ -11,7 +11,7 @@
 Brian  Gaeke   href=http://netfiles.uiuc.edu/gaeke/www/
img=PhotoBrian.png  width=155   height=163  alt=brg
 PatrickJenkins href=http://www.patjenk.comimg=PhotoPatJenk.jpg 
width=200  width=173  height=130  alt=PatJenk
 Brad   Jones   href=http://www.nondot.org/~kungfoomaster/  
img=PhotoBrad.jpg   width=200   height=171  alt=KungFooMaster
-JimLaskey  href=mailto:[EMAIL PROTECTED]   img=PhotoJim.jpg
width=128   height=128  alt=Wickund
+JimLaskey  href=mailto:[EMAIL PROTECTED]   img=PhotoJim.jpg
width=128   height=128  alt=Wickund
 Chris  Lattner href=http://nondot.org/sabre/LLVMNotes/ img=PhotoChris.jpg  
width=150   height=152  alt=Sabre
 Tanya  Lattner href=http://nondot.org/tonic/   img=PhotoTanya.jpg  
width=200   height=217  alt=tonic
 Andrew Lenharthhref=http://www.lenharth.org/~andrewl/  
img=PhotoAndrew.jpg width=140   height=177  alt=Andrew



___
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/InstructionCombining.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.643 -> 1.644
---
Log message:

simplify some code


---
Diffs of the changes:  (+17 -18)

 InstructionCombining.cpp |   35 +--
 1 files changed, 17 insertions(+), 18 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.643 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.644
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.643   Sat Mar  3 
22:27:24 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar  4 17:16:36 2007
@@ -850,6 +850,7 @@
 bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask,
 uint64_t &KnownZero, uint64_t 
&KnownOne,
 unsigned Depth) {
+  const IntegerType *VTy = cast(V->getType());
   if (ConstantInt *CI = dyn_cast(V)) {
 // We know all of the bits for a constant!
 KnownOne = CI->getZExtValue() & DemandedMask;
@@ -866,10 +867,10 @@
 }
 // If this is the root being simplified, allow it to have multiple uses,
 // just set the DemandedMask to all bits.
-DemandedMask = cast(V->getType())->getBitMask();
+DemandedMask = VTy->getBitMask();
   } else if (DemandedMask == 0) {   // Not demanding any bits from V.
-if (V != UndefValue::get(V->getType()))
-  return UpdateValueUsesWith(V, UndefValue::get(V->getType()));
+if (V != UndefValue::get(VTy))
+  return UpdateValueUsesWith(V, UndefValue::get(VTy));
 return false;
   } else if (Depth == 6) {// Limit search depth.
 return false;
@@ -878,7 +879,7 @@
   Instruction *I = dyn_cast(V);
   if (!I) return false;// Only analyze instructions.
 
-  DemandedMask &= cast(V->getType())->getBitMask();
+  DemandedMask &= VTy->getBitMask();
   
   uint64_t KnownZero2 = 0, KnownOne2 = 0;
   switch (I->getOpcode()) {
@@ -906,7 +907,7 @@
 
 // If all of the demanded bits in the inputs are known zeros, return zero.
 if ((DemandedMask & (KnownZero|KnownZero2)) == DemandedMask)
-  return UpdateValueUsesWith(I, Constant::getNullValue(I->getType()));
+  return UpdateValueUsesWith(I, Constant::getNullValue(VTy));
   
 // If the RHS is a constant, see if we can simplify it.
 if (ShrinkDemandedConstant(I, 1, DemandedMask & ~KnownZero2))
@@ -991,8 +992,7 @@
 //e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2
 if ((DemandedMask & (KnownZero|KnownOne)) == DemandedMask) { // all known
   if ((KnownOne & KnownOne2) == KnownOne) {
-Constant *AndC = ConstantInt::get(I->getType(), 
-  ~KnownOne & DemandedMask);
+Constant *AndC = ConstantInt::get(VTy, ~KnownOne & DemandedMask);
 Instruction *And = 
   BinaryOperator::createAnd(I->getOperand(0), AndC, "tmp");
 InsertNewInstBefore(And, *I);
@@ -1048,7 +1048,7 @@
 // Compute the bits in the result that are not present in the input.
 const IntegerType *SrcTy = cast(I->getOperand(0)->getType());
 uint64_t NotIn = ~SrcTy->getBitMask();
-uint64_t NewBits = cast(I->getType())->getBitMask() & NotIn;
+uint64_t NewBits = VTy->getBitMask() & NotIn;
 
 DemandedMask &= SrcTy->getBitMask();
 if (SimplifyDemandedBits(I->getOperand(0), DemandedMask,
@@ -1063,7 +1063,7 @@
 // Compute the bits in the result that are not present in the input.
 const IntegerType *SrcTy = cast(I->getOperand(0)->getType());
 uint64_t NotIn = ~SrcTy->getBitMask();
-uint64_t NewBits = cast(I->getType())->getBitMask() & NotIn;
+uint64_t NewBits = VTy->getBitMask() & NotIn;
 
 // Get the sign bit for the source type
 uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
@@ -1086,8 +1086,7 @@
 // convert this into a zero extension.
 if ((KnownZero & InSignBit) || (NewBits & ~DemandedMask) == NewBits) {
   // Convert to ZExt cast
-  CastInst *NewCast = CastInst::create(
-Instruction::ZExt, I->getOperand(0), I->getType(), I->getName(), I);
+  CastInst *NewCast = new ZExtInst(I->getOperand(0), VTy, I->getName(), I);
   return UpdateValueUsesWith(I, NewCast);
 } else if (KnownOne & InSignBit) {// Input sign bit known set
   KnownOne |= NewBits;
@@ -1112,7 +,7 @@
   // either.
   
   // Shift the demanded mask up so that it's at the top of the uint64_t.
-  unsigned BitWidth = I->getType()->getPrimitiveSizeInBits();
+  unsigned BitWidth = VTy->getPrimitiveSizeInBits();
   unsigned NLZ = CountLeadingZeros_64(DemandedMask << (64-BitWidth));
   
   // If the top bit of the output is demanded, demand everything from the
@@ -1208,8 +1207,8 @@
   
   // Compute the new bits that are at the top now.
   uint64_t HighBits = (1ULL << ShiftAmt)-1;
-  HighBits <<= I->getType()->getPrimitiveSizeInBit

[llvm-commits] CVS: llvm/include/llvm/Support/MathExtras.h

2007-03-04 Thread Chris Lattner


Changes in directory llvm/include/llvm/Support:

MathExtras.h updated: 1.41 -> 1.42
---
Log message:

fix 80 col violations, mark arrays static


---
Diffs of the changes:  (+12 -8)

 MathExtras.h |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)


Index: llvm/include/llvm/Support/MathExtras.h
diff -u llvm/include/llvm/Support/MathExtras.h:1.41 
llvm/include/llvm/Support/MathExtras.h:1.42
--- llvm/include/llvm/Support/MathExtras.h:1.41 Fri Mar  2 16:19:41 2007
+++ llvm/include/llvm/Support/MathExtras.h  Sun Mar  4 17:33:03 2007
@@ -205,9 +205,11 @@
 #if __GNUC__ >= 4
   return Value ? __builtin_ctz(Value) : 32;
 #else
-  const unsigned Mod37BitPosition[] = {32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 
30, 28, 11, 0, 13,
-   4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 
12, 6, 0, 21, 14, 9,
-   5, 20, 8, 19, 18 };
+  static const unsigned Mod37BitPosition[] = {
+32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13,
+4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9,
+5, 20, 8, 19, 18
+  };
   return Mod37BitPosition[(-Value & Value) % 37];
 #endif
 }
@@ -220,11 +222,13 @@
 #if __GNUC__ >= 4
   return Value ? __builtin_ctzll(Value) : 64;
 #else
-  const unsigned Mod67Position[] = {64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 
59, 41, 19, 24, 54,
-4, 64, 13, 10, 17, 62, 60, 28, 42, 30, 20, 
51, 25, 44, 55,
-47, 5, 32, 65, 38, 14, 22, 11, 58, 18, 53, 
63, 9, 61, 27,
-29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 
49, 45, 36, 56,
-7, 48, 35, 6, 34, 33, 0 };
+  static const unsigned Mod67Position[] = {
+64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 59, 41, 19, 24, 54,
+4, 64, 13, 10, 17, 62, 60, 28, 42, 30, 20, 51, 25, 44, 55,
+47, 5, 32, 65, 38, 14, 22, 11, 58, 18, 53, 63, 9, 61, 27,
+29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56,
+7, 48, 35, 6, 34, 33, 0
+  };
   return Mod67Position[(-Value & Value) % 67];
 #endif
 }



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


[llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h

2007-03-04 Thread Chris Lattner


Changes in directory llvm/include/llvm:

DerivedTypes.h updated: 1.86 -> 1.87
---
Log message:

add a getSignBit method, elimiante virtual method from getBitMask()


---
Diffs of the changes:  (+7 -1)

 DerivedTypes.h |8 +++-
 1 files changed, 7 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/DerivedTypes.h
diff -u llvm/include/llvm/DerivedTypes.h:1.86 
llvm/include/llvm/DerivedTypes.h:1.87
--- llvm/include/llvm/DerivedTypes.h:1.86   Wed Feb 28 22:02:06 2007
+++ llvm/include/llvm/DerivedTypes.hSun Mar  4 17:33:19 2007
@@ -106,9 +106,15 @@
   /// that can be set by an unsigned version of this type.  This is 0xFF for
   /// sbyte/ubyte, 0x for shorts, etc.
   uint64_t getBitMask() const {
-return ~uint64_t(0UL) >> (64-getPrimitiveSizeInBits());
+return ~uint64_t(0UL) >> (64-getBitWidth());
   }
 
+  /// getSignBit - Return a uint64_t with just the most significant bit set 
(the
+  /// sign bit, if the value is treated as a signed number).
+  uint64_t getSignBit() const {
+return 1ULL << (getBitWidth()-1);
+  }
+  
   /// For example, this is 0xFF for an 8 bit integer, 0x for i16, etc.
   /// @returns a bit mask with ones set for all the bits of this type.
   /// @brief Get a bit mask for this type.



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


Re: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h

2007-03-04 Thread Reid Spencer
Hi Chris,


On Sun, 2007-03-04 at 17:33 -0600, Chris Lattner wrote:
> 
> Changes in directory llvm/include/llvm:
> 
> DerivedTypes.h updated: 1.86 -> 1.87
> ---
> Log message:
> 
> add a getSignBit method, elimiante virtual method from getBitMask()
> 
> 
> ---
> Diffs of the changes:  (+7 -1)
> 
>  DerivedTypes.h |8 +++-
>  1 files changed, 7 insertions(+), 1 deletion(-)
> 
> 
> Index: llvm/include/llvm/DerivedTypes.h
> diff -u llvm/include/llvm/DerivedTypes.h:1.86 
> llvm/include/llvm/DerivedTypes.h:1.87
> --- llvm/include/llvm/DerivedTypes.h:1.86 Wed Feb 28 22:02:06 2007
> +++ llvm/include/llvm/DerivedTypes.h  Sun Mar  4 17:33:19 2007
> @@ -106,9 +106,15 @@
>/// that can be set by an unsigned version of this type.  This is 0xFF for
>/// sbyte/ubyte, 0x for shorts, etc.
>uint64_t getBitMask() const {
> -return ~uint64_t(0UL) >> (64-getPrimitiveSizeInBits());
> +return ~uint64_t(0UL) >> (64-getBitWidth());
>}
>  
> +  /// getSignBit - Return a uint64_t with just the most significant bit set 
> (the
> +  /// sign bit, if the value is treated as a signed number).
> +  uint64_t getSignBit() const {
> +return 1ULL << (getBitWidth()-1);
> +  }
> +  

I'm trying to get rid of such functions and you're adding more of
them :)

Please note that in many places (like the place you intend to use
getSignBit), it may be necessary to use APInt::getSignedMinValue() for
this value to enable it to work with > 64 bits. The exception to this is
GEP indexing which are known to be 32/64 bit indices. If your use is
similar, I suppose this is fine. If not, please note that when
InstructionCombining is done (Sheng's working on it), I intend to pass
through LLVM and get rid of calls to both of these functions, if
appropriate.

Reid.


>/// For example, this is 0xFF for an 8 bit integer, 0x for i16, etc.
>/// @returns a bit mask with ones set for all the bits of this type.
>/// @brief Get a bit mask for this type.
> 
> 
> 
> ___
> 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] CVS: llvm/lib/Analysis/ConstantFolding.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/Analysis:

ConstantFolding.cpp updated: 1.19 -> 1.20
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+2 -2)

 ConstantFolding.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Analysis/ConstantFolding.cpp
diff -u llvm/lib/Analysis/ConstantFolding.cpp:1.19 
llvm/lib/Analysis/ConstantFolding.cpp:1.20
--- llvm/lib/Analysis/ConstantFolding.cpp:1.19  Wed Feb 14 20:26:09 2007
+++ llvm/lib/Analysis/ConstantFolding.cpp   Sun Mar  4 18:00:41 2007
@@ -72,8 +72,8 @@
 // N = N + Offset
 Offset += TD.getStructLayout(ST)->getElementOffset(CI->getZExtValue());
   } else {
-const SequentialType *ST = cast(*GTI);
-Offset += TD.getTypeSize(ST->getElementType())*CI->getSExtValue();
+const SequentialType *SQT = cast(*GTI);
+Offset += TD.getTypeSize(SQT->getElementType())*CI->getSExtValue();
   }
 }
 return true;



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


[llvm-commits] CVS: llvm/win32/Support/Support.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/Support:

Support.vcproj updated: 1.17 -> 1.18
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+27 -3)

 Support.vcproj |   30 +++---
 1 files changed, 27 insertions(+), 3 deletions(-)


Index: llvm/win32/Support/Support.vcproj
diff -u llvm/win32/Support/Support.vcproj:1.17 
llvm/win32/Support/Support.vcproj:1.18
--- llvm/win32/Support/Support.vcproj:1.17  Fri Dec  1 20:22:01 2006
+++ llvm/win32/Support/Support.vcproj   Sun Mar  4 18:00:42 2007
@@ -116,6 +116,9 @@
RelativePath="..\..\lib\Support\Annotation.cpp">


+   
+   




+   
RelativePath="..\..\lib\Support\ConstantRange.cpp">


@@ -173,6 +176,9 @@



+   
+   




+   
+   




+   
+   



+   RelativePath="..\..\include\llvm\ADT\APInt.h">


+   
RelativePath="..\..\include\llvm\ADT\BitVector.h">


@@ -375,6 +387,9 @@
RelativePath="..\..\include\llvm\Adt\ilist">


+   
+   




+   
+   
+   
+   




+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolution.h

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/include/llvm/Analysis:

ScalarEvolution.h updated: 1.15 -> 1.16
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -0)

 ScalarEvolution.h |1 +
 1 files changed, 1 insertion(+)


Index: llvm/include/llvm/Analysis/ScalarEvolution.h
diff -u llvm/include/llvm/Analysis/ScalarEvolution.h:1.15 
llvm/include/llvm/Analysis/ScalarEvolution.h:1.16
--- llvm/include/llvm/Analysis/ScalarEvolution.h:1.15   Wed Feb 28 13:57:34 2007
+++ llvm/include/llvm/Analysis/ScalarEvolution.hSun Mar  4 18:00:41 2007
@@ -22,6 +22,7 @@
 #define LLVM_ANALYSIS_SCALAREVOLUTION_H
 
 #include "llvm/Pass.h"
+#include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Streams.h"
 #include 
 



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


[llvm-commits] CVS: llvm/include/llvm/Support/MathExtras.h

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/include/llvm/Support:

MathExtras.h updated: 1.42 -> 1.43
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -1)

 MathExtras.h |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/include/llvm/Support/MathExtras.h
diff -u llvm/include/llvm/Support/MathExtras.h:1.42 
llvm/include/llvm/Support/MathExtras.h:1.43
--- llvm/include/llvm/Support/MathExtras.h:1.42 Sun Mar  4 17:33:03 2007
+++ llvm/include/llvm/Support/MathExtras.h  Sun Mar  4 18:00:41 2007
@@ -255,7 +255,7 @@
   uint64_t v = Value - ((Value >> 1) & 0xULL);
   v = (v & 0xULL) + ((v >> 2) & 0xULL);
   v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
-  return (uint64_t)(v * 0x0101010101010101ULL) >> 56;
+  return unsigned((uint64_t)(v * 0x0101010101010101ULL) >> 56);
 #endif
 }
 



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


[llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp PassManager.cpp Value.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/VMCore:

Pass.cpp updated: 1.84 -> 1.85
PassManager.cpp updated: 1.138 -> 1.139
Value.cpp updated: 1.70 -> 1.71
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+3 -1)

 Pass.cpp|1 +
 PassManager.cpp |1 +
 Value.cpp   |2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)


Index: llvm/lib/VMCore/Pass.cpp
diff -u llvm/lib/VMCore/Pass.cpp:1.84 llvm/lib/VMCore/Pass.cpp:1.85
--- llvm/lib/VMCore/Pass.cpp:1.84   Tue Jan 30 14:08:38 2007
+++ llvm/lib/VMCore/Pass.cppSun Mar  4 18:00:42 2007
@@ -19,6 +19,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TypeInfo.h"
+#include 
 #include 
 using namespace llvm;
 


Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.138 
llvm/lib/VMCore/PassManager.cpp:1.139
--- llvm/lib/VMCore/PassManager.cpp:1.138   Tue Feb 27 09:00:39 2007
+++ llvm/lib/VMCore/PassManager.cpp Sun Mar  4 18:00:42 2007
@@ -19,6 +19,7 @@
 #include "llvm/ModuleProvider.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Support/ManagedStatic.h"
+#include 
 #include 
 #include 
 


Index: llvm/lib/VMCore/Value.cpp
diff -u llvm/lib/VMCore/Value.cpp:1.70 llvm/lib/VMCore/Value.cpp:1.71
--- llvm/lib/VMCore/Value.cpp:1.70  Thu Feb 15 14:01:43 2007
+++ llvm/lib/VMCore/Value.cpp   Sun Mar  4 18:00:42 2007
@@ -128,7 +128,7 @@
 
 void Value::setName(const char *NameStr, unsigned NameLen) {
   if (NameLen == 0 && !hasName()) return;
-  if (getType() != Type::VoidTy && "Cannot assign a name to void values!");
+  assert(getType() != Type::VoidTy && "Cannot assign a name to void values!");
   
   // Get the symbol table to update for this object.
   ValueSymbolTable *ST;



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


[llvm-commits] CVS: llvm/lib/Transforms/IPO/RaiseAllocations.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/Transforms/IPO:

RaiseAllocations.cpp updated: 1.39 -> 1.40
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -0)

 RaiseAllocations.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Transforms/IPO/RaiseAllocations.cpp
diff -u llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.39 
llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.40
--- llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.39   Sat Feb 10 19:08:35 2007
+++ llvm/lib/Transforms/IPO/RaiseAllocations.cppSun Mar  4 18:00:42 2007
@@ -22,6 +22,7 @@
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/ADT/Statistic.h"
+#include 
 using namespace llvm;
 
 STATISTIC(NumRaised, "Number of allocations raised");



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


[llvm-commits] CVS: llvm/win32/Bytecode/Bytecode.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/Bytecode:

Bytecode.vcproj updated: 1.6 -> 1.7
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+0 -3)

 Bytecode.vcproj |3 ---
 1 files changed, 3 deletions(-)


Index: llvm/win32/Bytecode/Bytecode.vcproj
diff -u llvm/win32/Bytecode/Bytecode.vcproj:1.6 
llvm/win32/Bytecode/Bytecode.vcproj:1.7
--- llvm/win32/Bytecode/Bytecode.vcproj:1.6 Sun Jan 29 22:07:07 2006
+++ llvm/win32/Bytecode/Bytecode.vcproj Sun Mar  4 18:00:42 2007
@@ -134,9 +134,6 @@

RelativePath="..\..\lib\Bytecode\Writer\SlotCalculator.h">


-   
-   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/Analysis/IPA:

Andersens.cpp updated: 1.45 -> 1.46
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -0)

 Andersens.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Analysis/IPA/Andersens.cpp
diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.45 
llvm/lib/Analysis/IPA/Andersens.cpp:1.46
--- llvm/lib/Analysis/IPA/Andersens.cpp:1.45Mon Feb  5 17:42:17 2007
+++ llvm/lib/Analysis/IPA/Andersens.cpp Sun Mar  4 18:00:42 2007
@@ -62,6 +62,7 @@
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/Statistic.h"
+#include 
 #include 
 using namespace llvm;
 



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


[llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/tools/llvm-prof:

llvm-prof.cpp updated: 1.30 -> 1.31
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -0)

 llvm-prof.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/tools/llvm-prof/llvm-prof.cpp
diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.30 
llvm/tools/llvm-prof/llvm-prof.cpp:1.31
--- llvm/tools/llvm-prof/llvm-prof.cpp:1.30 Wed Feb  7 15:41:02 2007
+++ llvm/tools/llvm-prof/llvm-prof.cpp  Sun Mar  4 18:00:42 2007
@@ -21,6 +21,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/System/Signals.h"
+#include 
 #include 
 #include 
 #include 



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


[llvm-commits] CVS: llvm/win32/x86/x86.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/x86:

x86.vcproj updated: 1.25 -> 1.26
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+38 -7)

 x86.vcproj |   45 ++---
 1 files changed, 38 insertions(+), 7 deletions(-)


Index: llvm/win32/x86/x86.vcproj
diff -u llvm/win32/x86/x86.vcproj:1.25 llvm/win32/x86/x86.vcproj:1.26
--- llvm/win32/x86/x86.vcproj:1.25  Sun Nov  5 13:31:28 2006
+++ llvm/win32/x86/x86.vcproj   Sun Mar  4 18:00:42 2007
@@ -116,36 +116,58 @@

+   
AdditionalDependencies="$(InputDir)X86InstrInfo.td;$(InputDir)X86RegisterInfo.td;$(InputDir)X86InstrFPStack.td;$(InputDir)X86InstrMMX.td;$(InputDir)X86InstrSSE.td;$(InputDir)X86CallingConv.td;$(InputDir)..\Target.td;$(InputDir)..\TargetSchedule.td;$(InputDir)..\TargetScheduleDAG.td;$(ProjectDir)..\$(IntDir)\TableGen.exe"
+   
Outputs="X86GenRegisterNames.inc;X86GenRegisterInfo.h.inc;X86GenRegisterInfo.inc;X86GenInstrNames.inc;X86GenInstrInfo.inc;X86GenAsmWriter.inc;X86GenAsmWriter1.inc;X86GenDAGISel.inc;X86GenSubtarget.inc;X86GenCallingConv.inc"/>



+   
AdditionalDependencies="$(InputDir)X86InstrInfo.td;$(InputDir)X86RegisterInfo.td;$(InputDir)X86InstrFPStack.td;$(InputDir)X86InstrMMX.td;$(InputDir)X86InstrSSE.td;$(InputDir)X86CallingConv.td;$(InputDir)..\Target.td;$(InputDir)..\TargetSchedule.td;$(InputDir)..\TargetScheduleDAG.td;$(ProjectDir)..\$(IntDir)\TableGen.exe"
+   
Outputs="X86GenRegisterNames.inc;X86GenRegisterInfo.h.inc;X86GenRegisterInfo.inc;X86GenInstrNames.inc;X86GenInstrInfo.inc;X86GenAsmWriter.inc;X86GenAsmWriter1.inc;X86GenDAGISel.inc;X86GenSubtarget.inc;X86GenCallingConv.inc"/>





+   RelativePath="..\..\lib\Target\X86\X86COFF.h">
+   
+   
+   
+   


@@ -214,6 +242,9 @@

RelativePath="..\..\lib\Target\X86\X86ATTAsmPrinter.h">


+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/win32/CodeGen/CodeGen.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/CodeGen:

CodeGen.vcproj updated: 1.26 -> 1.27
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+29 -5)

 CodeGen.vcproj |   34 +-
 1 files changed, 29 insertions(+), 5 deletions(-)


Index: llvm/win32/CodeGen/CodeGen.vcproj
diff -u llvm/win32/CodeGen/CodeGen.vcproj:1.26 
llvm/win32/CodeGen/CodeGen.vcproj:1.27
--- llvm/win32/CodeGen/CodeGen.vcproj:1.26  Mon Jan 15 14:27:18 2007
+++ llvm/win32/CodeGen/CodeGen.vcproj   Sun Mar  4 18:00:42 2007
@@ -121,6 +121,9 @@
RelativePath="..\..\lib\CodeGen\ELFWriter.cpp">


+   
+   




-   
-   




+   
+   


+   
+   
+   
+   




+   
+   



+   
+   




+   
+   


+   
RelativePath="..\..\include\llvm\CodeGen\FileWriters.h">


@@ -274,13 +292,16 @@

RelativePath="..\..\include\llvm\CodeGen\MachineLocation.h">


+   
+   




+   
RelativePath="..\..\include\llvm\CodeGen\MachORelocation.h">


@@ -292,6 +313,9 @@

RelativePath="..\..\include\llvm\CodeGen\RegAllocRegistry.h">


+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/win32/VMCore/VMCore.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/VMCore:

VMCore.vcproj updated: 1.26 -> 1.27
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+6 -10)

 VMCore.vcproj |   16 ++--
 1 files changed, 6 insertions(+), 10 deletions(-)


Index: llvm/win32/VMCore/VMCore.vcproj
diff -u llvm/win32/VMCore/VMCore.vcproj:1.26 
llvm/win32/VMCore/VMCore.vcproj:1.27
--- llvm/win32/VMCore/VMCore.vcproj:1.26Mon Jan 15 14:27:18 2007
+++ llvm/win32/VMCore/VMCore.vcproj Sun Mar  4 18:00:42 2007
@@ -116,7 +116,7 @@
RelativePath="..\..\lib\VMCore\BasicBlock.cpp">


+   
RelativePath="..\..\lib\VMCore\ConstantFold.cpp">


@@ -149,7 +149,8 @@

@@ -159,7 +160,8 @@

@@ -184,9 +186,6 @@
RelativePath="..\..\lib\VMCore\PassManager.cpp">


-   
-   




+   RelativePath="..\..\lib\VMCore\ConstantFold.h">


@@ -300,9 +299,6 @@

RelativePath="..\..\include\llvm\Assembly\PrintModulePass.h">


-   
-   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/win32/System/System.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/System:

System.vcproj updated: 1.18 -> 1.19
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+6 -0)

 System.vcproj |6 ++
 1 files changed, 6 insertions(+)


Index: llvm/win32/System/System.vcproj
diff -u llvm/win32/System/System.vcproj:1.18 
llvm/win32/System/System.vcproj:1.19
--- llvm/win32/System/System.vcproj:1.18Sun Nov  5 13:31:28 2006
+++ llvm/win32/System/System.vcproj Sun Mar  4 18:00:42 2007
@@ -113,6 +113,9 @@
RelativePath="..\..\lib\System\Alarm.cpp">


+   
+   




+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/tools/llvm-nm/llvm-nm.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/tools/llvm-nm:

llvm-nm.cpp updated: 1.31 -> 1.32
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -0)

 llvm-nm.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/tools/llvm-nm/llvm-nm.cpp
diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.31 llvm/tools/llvm-nm/llvm-nm.cpp:1.32
--- llvm/tools/llvm-nm/llvm-nm.cpp:1.31 Wed Feb  7 15:41:02 2007
+++ llvm/tools/llvm-nm/llvm-nm.cpp  Sun Mar  4 18:00:42 2007
@@ -22,6 +22,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/System/Signals.h"
+#include 
 #include 
 #include 
 #include 



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


[llvm-commits] CVS: llvm/lib/Support/APInt.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.68 -> 1.69
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+9 -1)

 APInt.cpp |   10 +-
 1 files changed, 9 insertions(+), 1 deletion(-)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.68 llvm/lib/Support/APInt.cpp:1.69
--- llvm/lib/Support/APInt.cpp:1.68 Fri Mar  2 16:39:11 2007
+++ llvm/lib/Support/APInt.cpp  Sun Mar  4 18:00:42 2007
@@ -17,6 +17,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
+#include 
 #include 
 #include 
 #ifndef NDEBUG
@@ -1224,9 +1225,16 @@
   // an IEEE double precision floating point value), then we can use the
   // libc sqrt function which will probably use a hardware sqrt computation.
   // This should be faster than the algorithm below.
-  if (magnitude < 52)
+  if (magnitude < 52) {
+#ifdef _MSC_VER
+// Amazingly, VC++ doesn't have round().
+return APInt(BitWidth, 
+ uint64_t(::sqrt(double(isSingleWord()?VAL:pVal[0]))) + 0.5);
+#else
 return APInt(BitWidth, 
  
uint64_t(::round(::sqrt(double(isSingleWord()?VAL:pVal[0]);
+#endif
+  }
 
   // Okay, all the short cuts are exhausted. We must compute it. The following
   // is a classical Babylonian method for computing the square root. This code



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


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.379 -> 1.380
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -1)

 SelectionDAGISel.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.379 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.380
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.379Thu Mar  1 
14:24:30 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Sun Mar  4 18:00:42 2007
@@ -3301,7 +3301,7 @@
 // Flags[2] -> isSRet
 // Flags[1] -> isInReg
 // Flags[0] -> isSigned
-unsigned Flags = (isSRet << 2) | (isInReg << 1) | isSigned |
+unsigned Flags = (isSRet << 2) | (isInReg << 1) | unsigned(isSigned) |
   (OriginalAlignment << 27);
 
 switch (getTypeAction(VT)) {



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


[llvm-commits] CVS: llvm/include/llvm/ADT/SmallVector.h

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/include/llvm/ADT:

SmallVector.h updated: 1.24 -> 1.25
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+19 -0)

 SmallVector.h |   19 +++
 1 files changed, 19 insertions(+)


Index: llvm/include/llvm/ADT/SmallVector.h
diff -u llvm/include/llvm/ADT/SmallVector.h:1.24 
llvm/include/llvm/ADT/SmallVector.h:1.25
--- llvm/include/llvm/ADT/SmallVector.h:1.24Tue Feb 13 01:25:36 2007
+++ llvm/include/llvm/ADT/SmallVector.h Sun Mar  4 18:00:41 2007
@@ -18,6 +18,25 @@
 #include 
 #include 
 
+#ifdef _MSC_VER
+namespace std {
+  // Fix bug in VC++ implementation of std::uninitialized_copy.  Define
+  // additional overloads so that the copy is recognized as a scalar and
+  // not an object copy.
+  template
+  inline _Scalar_ptr_iterator_tag _Ptr_cat(T1 **, T2 **) {
+ _Scalar_ptr_iterator_tag _Cat;
+ return _Cat;
+  }
+
+  template
+  inline _Scalar_ptr_iterator_tag _Ptr_cat(T1* const *, T2 **) {
+ _Scalar_ptr_iterator_tag _Cat;
+ return _Cat;
+  }
+}
+#endif
+
 namespace llvm {
 
 /// SmallVectorImpl - This class consists of common code factored out of the



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


[llvm-commits] CVS: llvm/win32/Analysis/Analysis.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/Analysis:

Analysis.vcproj updated: 1.22 -> 1.23
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+6 -3)

 Analysis.vcproj |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)


Index: llvm/win32/Analysis/Analysis.vcproj
diff -u llvm/win32/Analysis/Analysis.vcproj:1.22 
llvm/win32/Analysis/Analysis.vcproj:1.23
--- llvm/win32/Analysis/Analysis.vcproj:1.22Fri Dec 15 15:47:01 2006
+++ llvm/win32/Analysis/Analysis.vcproj Sun Mar  4 18:00:42 2007
@@ -133,9 +133,6 @@

RelativePath="..\..\lib\Analysis\ConstantFolding.cpp">


-   
-   




+   
+   




+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/win32/Transforms/Transforms.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/Transforms:

Transforms.vcproj updated: 1.24 -> 1.25
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+3 -21)

 Transforms.vcproj |   24 +++-
 1 files changed, 3 insertions(+), 21 deletions(-)


Index: llvm/win32/Transforms/Transforms.vcproj
diff -u llvm/win32/Transforms/Transforms.vcproj:1.24 
llvm/win32/Transforms/Transforms.vcproj:1.25
--- llvm/win32/Transforms/Transforms.vcproj:1.24Mon Jan  8 14:17:17 2007
+++ llvm/win32/Transforms/Transforms.vcproj Sun Mar  4 18:00:42 2007
@@ -108,18 +108,6 @@
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"

UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
-   
-   
-   
-   
-   
-   
-   
-   

@@ -130,9 +118,6 @@

RelativePath="..\..\lib\Transforms\Instrumentation\EdgeProfiling.cpp">


-   
-   



-   
-   




-   
-   




+   
+   





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


[llvm-commits] CVS: llvm/win32/Target/Target.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/Target:

Target.vcproj updated: 1.15 -> 1.16
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+9 -0)

 Target.vcproj |9 +
 1 files changed, 9 insertions(+)


Index: llvm/win32/Target/Target.vcproj
diff -u llvm/win32/Target/Target.vcproj:1.15 
llvm/win32/Target/Target.vcproj:1.16
--- llvm/win32/Target/Target.vcproj:1.15Sun Nov  5 13:31:28 2006
+++ llvm/win32/Target/Target.vcproj Sun Mar  4 18:00:42 2007
@@ -133,6 +133,9 @@

RelativePath="..\..\lib\Target\TargetMachineRegistry.cpp">


+   
+   


@@ -153,6 +156,9 @@

RelativePath="..\..\include\llvm\Target\TargetData.h">


+   
+   




+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/win32/TableGen/TableGen.vcproj

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/win32/TableGen:

TableGen.vcproj updated: 1.21 -> 1.22
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+6 -0)

 TableGen.vcproj |6 ++
 1 files changed, 6 insertions(+)


Index: llvm/win32/TableGen/TableGen.vcproj
diff -u llvm/win32/TableGen/TableGen.vcproj:1.21 
llvm/win32/TableGen/TableGen.vcproj:1.22
--- llvm/win32/TableGen/TableGen.vcproj:1.21Fri Mar  3 20:19:46 2006
+++ llvm/win32/TableGen/TableGen.vcproj Sun Mar  4 18:00:42 2007
@@ -129,6 +129,9 @@

RelativePath="..\..\utils\TableGen\AsmWriterEmitter.cpp">


+   
+   




+   
+   

http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp PredicateSimplifier.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.644 -> 1.645
PredicateSimplifier.cpp updated: 1.54 -> 1.55
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+2 -1)

 InstructionCombining.cpp |1 +
 PredicateSimplifier.cpp  |2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.644 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.645
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.644   Sun Mar  4 
17:16:36 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar  4 18:00:42 2007
@@ -7663,6 +7663,7 @@
PhiVal, ConstantOp);
   else
 assert(0 && "Unknown operation");
+  return 0;
 }
 
 /// DeadPHICycle - Return true if this PHI node is only used by a PHI node 
cycle


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.54 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.55
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.54 Fri Mar  2 
21:14:40 2007
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Sun Mar  4 18:00:42 2007
@@ -421,7 +421,7 @@
   iSGT = iUGT;
   iSLT = iULT;
 } else {
-  assert(iULT->first->getValue().isPositive() >= 0 &&
+  assert(iULT->first->getValue().isPositive() &&
  iUGT->first->getValue().isNegative() &&"Bad sign 
comparison.");
   iSGT = iULT;
   iSLT = iUGT;



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


[llvm-commits] CVS: llvm/test/Transforms/InstCombine/add2.ll

2007-03-04 Thread Chris Lattner


Changes in directory llvm/test/Transforms/InstCombine:

add2.ll added (r1.1)
---
Log message:

new testcase


---
Diffs of the changes:  (+12 -0)

 add2.ll |   12 
 1 files changed, 12 insertions(+)


Index: llvm/test/Transforms/InstCombine/add2.ll
diff -c /dev/null llvm/test/Transforms/InstCombine/add2.ll:1.1
*** /dev/null   Sun Mar  4 18:01:48 2007
--- llvm/test/Transforms/InstCombine/add2.llSun Mar  4 18:01:38 2007
***
*** 0 
--- 1,12 
+ ; RUN: llvm-as < %s | opt -instcombine -disable-output &&
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
+ ; RUN:grep -v OK | not grep add
+ 
+ define i64 @test1(i64 %A, i32 %B) {
+ %tmp12 = zext i32 %B to i64
+ %tmp3 = shl i64 %tmp12, 32
+ %tmp5 = add i64 %tmp3, %A
+ %tmp6 = and i64 %tmp5, 123
+ ret i64 %tmp6
+ }
+ 



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


[llvm-commits] CVS: llvm/lib/Target/TargetData.cpp

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/Target:

TargetData.cpp updated: 1.104 -> 1.105
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+1 -1)

 TargetData.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.104 
llvm/lib/Target/TargetData.cpp:1.105
--- llvm/lib/Target/TargetData.cpp:1.104Thu Mar  1 13:48:16 2007
+++ llvm/lib/Target/TargetData.cpp  Sun Mar  4 18:00:42 2007
@@ -400,7 +400,7 @@
 unsigned char Alignment;
 Size = getTypeSize(ATy->getElementType());
 Alignment = getABITypeAlignment(ATy->getElementType());
-unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment;
+uint64_t AlignedSize = (Size + Alignment - 1)/Alignment*Alignment;
 return AlignedSize*ATy->getNumElements();
   }
   case Type::StructTyID: {



___
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/InstructionCombining.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.645 -> 1.646
---
Log message:

Add some simplifications for demanded bits, this allows instcombine to turn:

define i64 @test(i64 %A, i32 %B) {
%tmp12 = zext i32 %B to i64 ;  [#uses=1]
%tmp3 = shl i64 %tmp12, 32  ;  [#uses=1]
%tmp5 = add i64 %tmp3, %A   ;  [#uses=1]
%tmp6 = and i64 %tmp5, 123  ;  [#uses=1]
ret i64 %tmp6
}

into:

define i64 @test(i64 %A, i32 %B) {
%tmp6 = and i64 %A, 123 ;  [#uses=1]
ret i64 %tmp6
}

This implements Transforms/InstCombine/add2.ll:test1




---
Diffs of the changes:  (+31 -0)

 InstructionCombining.cpp |   31 +++
 1 files changed, 31 insertions(+)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.645 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.646
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.645   Sun Mar  4 
18:00:42 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar  4 18:02:29 2007
@@ -1186,6 +1186,37 @@
   // Bits are known zero if they are known zero in both operands and there
   // is no input carry.
   KnownZero = KnownZero2 & ~RHSVal & ~CarryBits;
+} else {
+  // If the high-bits of this ADD are not demanded, then it does not demand
+  // the high bits of its LHS or RHS.
+  if ((DemandedMask & VTy->getSignBit()) == 0) {
+// Right fill the mask of bits for this ADD to demand the most
+// significant bit and all those below it.
+unsigned NLZ = CountLeadingZeros_64(DemandedMask);
+uint64_t DemandedFromOps = ~0ULL >> NLZ;
+if (SimplifyDemandedBits(I->getOperand(0), DemandedFromOps,
+ KnownZero2, KnownOne2, Depth+1))
+  return true;
+if (SimplifyDemandedBits(I->getOperand(1), DemandedFromOps,
+ KnownZero2, KnownOne2, Depth+1))
+  return true;
+  }
+}
+break;
+  case Instruction::Sub:
+// If the high-bits of this SUB are not demanded, then it does not demand
+// the high bits of its LHS or RHS.
+if ((DemandedMask & VTy->getSignBit()) == 0) {
+  // Right fill the mask of bits for this SUB to demand the most
+  // significant bit and all those below it.
+  unsigned NLZ = CountLeadingZeros_64(DemandedMask);
+  uint64_t DemandedFromOps = ~0ULL >> NLZ;
+  if (SimplifyDemandedBits(I->getOperand(0), DemandedFromOps,
+   KnownZero2, KnownOne2, Depth+1))
+return true;
+  if (SimplifyDemandedBits(I->getOperand(1), DemandedFromOps,
+   KnownZero2, KnownOne2, Depth+1))
+return true;
 }
 break;
   case Instruction::Shl:



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


Re: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h

2007-03-04 Thread Chris Lattner
>> +  /// getSignBit - Return a uint64_t with just the most  
>> significant bit set (the
>> +  /// sign bit, if the value is treated as a signed number).
>> +  uint64_t getSignBit() const {
>> +return 1ULL << (getBitWidth()-1);
>> +  }
>> +
>
> I'm trying to get rid of such functions and you're adding more of
> them :)

The thought occurred to me :).  However, this is used in  
InstCombiner::SimplifyDemandedBits, which will require significant  
work to APInt'ify.  Using a function like this (instead of localized  
bit-twiddling) will at least help distill the intention out of the code.

> Please note that in many places (like the place you intend to use
> getSignBit), it may be necessary to use APInt::getSignedMinValue() for
> this value to enable it to work with > 64 bits. The exception to  
> this is
> GEP indexing which are known to be 32/64 bit indices. If your use is
> similar, I suppose this is fine. If not, please note that when
> InstructionCombining is done (Sheng's working on it), I intend to pass
> through LLVM and get rid of calls to both of these functions, if
> appropriate.

I strongly encourage Sheng to do instcombine one piece at a time: say  
visitAND, then visitOR (etc) and submit them as separate patches.

Blasting me with one huge patch is not going to earn brownie points,  
and if/when it breaks something, it won't be easy to track down what  
part of the huge change did it.

-Chris
___
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/InstructionCombining.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.646 -> 1.647
---
Log message:

fix a subtle bug that caused an MSVC warning.  Thanks to Jeffc for pointing 
this out.


---
Diffs of the changes:  (+3 -2)

 InstructionCombining.cpp |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.646 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.647
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.646   Sun Mar  4 
18:02:29 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Mar  4 18:11:19 2007
@@ -5559,10 +5559,11 @@
   
   // Turn (Y + ((X >> C) & CC)) << C  ->  ((X & (CC << C)) + (Y << C))
   Value *Op0BOOp1 = Op0BO->getOperand(1);
-  if (isLeftShift && Op0BOOp1->hasOneUse() && V2 == Op1 &&
+  if (isLeftShift && Op0BOOp1->hasOneUse() &&
   match(Op0BOOp1, 
 m_And(m_Shr(m_Value(V1), m_Value(V2)),m_ConstantInt(CC))) 
&&
-  cast(Op0BOOp1)->getOperand(0)-> hasOneUse()) {
+  cast(Op0BOOp1)->getOperand(0)->hasOneUse() &&
+  V2 == Op1) {
 Instruction *YS = BinaryOperator::createShl(
  Op0BO->getOperand(0), Op1,
  Op0BO->getName());



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


[llvm-commits] CVS: llvm/include/llvm/ADT/SmallVector.h

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/include/llvm/ADT:

SmallVector.h updated: 1.25 -> 1.26
---
Log message:

Elminate tabs and improve comments.

---
Diffs of the changes:  (+8 -7)

 SmallVector.h |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)


Index: llvm/include/llvm/ADT/SmallVector.h
diff -u llvm/include/llvm/ADT/SmallVector.h:1.25 
llvm/include/llvm/ADT/SmallVector.h:1.26
--- llvm/include/llvm/ADT/SmallVector.h:1.25Sun Mar  4 18:00:41 2007
+++ llvm/include/llvm/ADT/SmallVector.h Sun Mar  4 18:46:22 2007
@@ -20,19 +20,20 @@
 
 #ifdef _MSC_VER
 namespace std {
-  // Fix bug in VC++ implementation of std::uninitialized_copy.  Define
-  // additional overloads so that the copy is recognized as a scalar and
-  // not an object copy.
+  // Work around flawed VC++ implementation of std::uninitialized_copy.  Define
+  // additional overloads so that elements with pointer types are recognized as
+  // scalars and not objects, causing bizarre type conversion errors.
+  // FIXME: this hack may or may not be correct for Visual Studio 2005.
   template
   inline _Scalar_ptr_iterator_tag _Ptr_cat(T1 **, T2 **) {
- _Scalar_ptr_iterator_tag _Cat;
- return _Cat;
+_Scalar_ptr_iterator_tag _Cat;
+return _Cat;
   }
 
   template
   inline _Scalar_ptr_iterator_tag _Ptr_cat(T1* const *, T2 **) {
- _Scalar_ptr_iterator_tag _Cat;
- return _Cat;
+_Scalar_ptr_iterator_tag _Cat;
+return _Cat;
   }
 }
 #endif



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


Re: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h

2007-03-04 Thread Reid Spencer
On Sun, 2007-03-04 at 16:05 -0800, Chris Lattner wrote:
> >
> The thought occurred to me :).  However, this is used in  
> InstCombiner::SimplifyDemandedBits, which will require significant  
> work to APInt'ify.  Using a function like this (instead of localized  
> bit-twiddling) will at least help distill the intention out of the code.

Okay :)

> I strongly encourage Sheng to do instcombine one piece at a time: say  
> visitAND, then visitOR (etc) and submit them as separate patches.

I have requested that he submit daily (if not more frequent) patches.

> Blasting me with one huge patch is not going to earn brownie points,  
> and if/when it breaks something, it won't be easy to track down what  
> part of the huge change did it.

Yes, I'm well aware of that. And its not just you. I will review each of
these patches before you ever see it.

> 
> -Chris

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


Re: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h

2007-03-04 Thread Chris Lattner
>> I strongly encourage Sheng to do instcombine one piece at a time: say
>> visitAND, then visitOR (etc) and submit them as separate patches.
>
> I have requested that he submit daily (if not more frequent) patches.

Thanks!

>> Blasting me with one huge patch is not going to earn brownie points,
>> and if/when it breaks something, it won't be easy to track down what
>> part of the huge change did it.
>
> Yes, I'm well aware of that. And its not just you. I will review  
> each of
> these patches before you ever see it.

Great!

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


[llvm-commits] CVS: llvm/lib/System/Win32/Program.inc Win32.h

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Program.inc updated: 1.19 -> 1.20
Win32.h updated: 1.10 -> 1.11
---
Log message:

Implement memoryLimit on Windows.

---
Diffs of the changes:  (+52 -6)

 Program.inc |   37 +++--
 Win32.h |   21 +
 2 files changed, 52 insertions(+), 6 deletions(-)


Index: llvm/lib/System/Win32/Program.inc
diff -u llvm/lib/System/Win32/Program.inc:1.19 
llvm/lib/System/Win32/Program.inc:1.20
--- llvm/lib/System/Win32/Program.inc:1.19  Fri Feb 16 13:11:06 2007
+++ llvm/lib/System/Win32/Program.inc   Sun Mar  4 23:22:07 2007
@@ -93,8 +93,8 @@
   if (h == INVALID_HANDLE_VALUE) {
 MakeErrMsg(ErrMsg, std::string(fname) + ": Can't open file for " +
 (fd ? "input: " : "output: "));
-return h;
   }
+
   return h;
 }
 
@@ -179,7 +179,7 @@
   0, TRUE, DUPLICATE_SAME_ACCESS);
 }
   }
-
+  
   PROCESS_INFORMATION pi;
   memset(&pi, 0, sizeof(pi));
 
@@ -204,6 +204,35 @@
 return -1;
   }
 
+  // Make sure these get closed no matter what.
+  AutoHandle hProcess(pi.hProcess);
+  AutoHandle hThread(pi.hThread);
+
+  // Assign the process to a job if a memory limit is defined.
+  AutoHandle hJob(0);
+  if (memoryLimit != 0) {
+hJob = CreateJobObject(0, 0);
+bool success = false;
+if (hJob != 0) {
+  JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli;
+  memset(&jeli, 0, sizeof(jeli));
+  jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_PROCESS_MEMORY;
+  jeli.ProcessMemoryLimit = memoryLimit * 1048576;
+  if (SetInformationJobObject(hJob, JobObjectExtendedLimitInformation,
+  &jeli, sizeof(jeli))) {
+if (AssignProcessToJobObject(hJob, pi.hProcess))
+  success = true;
+  }
+}
+if (!success) {
+  SetLastError(GetLastError());
+  MakeErrMsg(ErrMsg, std::string("Unable to set memory limit"));
+  TerminateProcess(pi.hProcess, 1);
+  WaitForSingleObject(pi.hProcess, INFINITE);
+  return -1;
+}
+  }
+
   // Wait for it to terminate.
   DWORD millisecondsToWait = INFINITE;
   if (secondsToWait > 0)
@@ -223,10 +252,6 @@
   rc = GetExitCodeProcess(pi.hProcess, &status);
   err = GetLastError();
 
-  // Done with the handles; go close them.
-  CloseHandle(pi.hProcess);
-  CloseHandle(pi.hThread);
-
   if (!rc) {
 SetLastError(err);
 MakeErrMsg(ErrMsg, std::string("Failed getting status for program '") + 


Index: llvm/lib/System/Win32/Win32.h
diff -u llvm/lib/System/Win32/Win32.h:1.10 llvm/lib/System/Win32/Win32.h:1.11
--- llvm/lib/System/Win32/Win32.h:1.10  Fri Sep  1 15:35:17 2006
+++ llvm/lib/System/Win32/Win32.h   Sun Mar  4 23:22:08 2007
@@ -34,3 +34,24 @@
   LocalFree(buffer);
   return true;
 }
+
+class AutoHandle {
+  HANDLE handle;
+
+public:
+  AutoHandle(HANDLE h) : handle(h) {}
+
+  ~AutoHandle() {
+if (handle)
+  CloseHandle(handle);
+  }
+
+  operator HANDLE() {
+return handle;
+  }
+
+  AutoHandle &operator=(HANDLE h) {
+handle = h;
+return *this;
+  }
+};



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


[llvm-commits] CVS: llvm/lib/System/Win32/Program.inc

2007-03-04 Thread Jeff Cohen


Changes in directory llvm/lib/System/Win32:

Program.inc updated: 1.20 -> 1.21
---
Log message:

Ensure 64-bit correctness.

---
Diffs of the changes:  (+1 -1)

 Program.inc |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/System/Win32/Program.inc
diff -u llvm/lib/System/Win32/Program.inc:1.20 
llvm/lib/System/Win32/Program.inc:1.21
--- llvm/lib/System/Win32/Program.inc:1.20  Sun Mar  4 23:22:07 2007
+++ llvm/lib/System/Win32/Program.inc   Sun Mar  4 23:45:08 2007
@@ -217,7 +217,7 @@
   JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli;
   memset(&jeli, 0, sizeof(jeli));
   jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_PROCESS_MEMORY;
-  jeli.ProcessMemoryLimit = memoryLimit * 1048576;
+  jeli.ProcessMemoryLimit = uintptr_t(memoryLimit) * 1048576;
   if (SetInformationJobObject(hJob, JobObjectExtendedLimitInformation,
   &jeli, sizeof(jeli))) {
 if (AssignProcessToJobObject(hJob, pi.hProcess))



___
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/ScalarReplAggregates.cpp

2007-03-04 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

ScalarReplAggregates.cpp updated: 1.75 -> 1.76
---
Log message:

This is the first major step of implementing PR1226: http://llvm.org/PR1226 .  
We now successfully
scalarrepl things down to elements, but mem2reg can't promote elements that
are memset/memcpy'd.  Until then, the code is disabled "0 &&".



---
Diffs of the changes:  (+156 -5)

 ScalarReplAggregates.cpp |  161 +--
 1 files changed, 156 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.75 
llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.76
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.75Wed Feb 14 
21:39:18 2007
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Mar  5 01:52:57 2007
@@ -24,8 +24,9 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
-#include "llvm/Pass.h"
 #include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
+#include "llvm/Pass.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
@@ -60,11 +61,15 @@
 
   private:
 int isSafeElementUse(Value *Ptr);
-int isSafeUseOfAllocation(Instruction *User);
+int isSafeUseOfAllocation(Instruction *User, AllocationInst *AI);
+bool isSafeUseOfBitCastedAllocation(BitCastInst *User, AllocationInst *AI);
 int isSafeAllocaToScalarRepl(AllocationInst *AI);
 void CanonicalizeAllocaUsers(AllocationInst *AI);
 AllocaInst *AddNewAlloca(Function &F, const Type *Ty, AllocationInst 
*Base);
 
+void RewriteBitCastUserOfAlloca(BitCastInst *BCInst, AllocationInst *AI,
+SmallVector &NewElts);
+
 const Type *CanConvertToScalar(Value *V, bool &IsNotTrivial);
 void ConvertToScalar(AllocationInst *AI, const Type *Ty);
 void ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset);
@@ -180,7 +185,7 @@
 DOUT << "Found inst to xform: " << *AI;
 Changed = true;
 
-std::vector ElementAllocas;
+SmallVector ElementAllocas;
 if (const StructType *ST = dyn_cast(AI->getAllocatedType())) {
   ElementAllocas.reserve(ST->getNumContainedTypes());
   for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
@@ -207,6 +212,11 @@
 //
 while (!AI->use_empty()) {
   Instruction *User = cast(AI->use_back());
+  if (BitCastInst *BCInst = dyn_cast(User)) {
+RewriteBitCastUserOfAlloca(BCInst, AI, ElementAllocas);
+continue;
+  }
+  
   GetElementPtrInst *GEPI = cast(User);
   // We now know that the GEP is of the form: GEP , 0, 
   unsigned Idx =
@@ -291,7 +301,9 @@
 /// isSafeUseOfAllocation - Check to see if this user is an allowed use for an
 /// aggregate allocation.
 ///
-int SROA::isSafeUseOfAllocation(Instruction *User) {
+int SROA::isSafeUseOfAllocation(Instruction *User, AllocationInst *AI) {
+  if (BitCastInst *C = dyn_cast(User))
+return 0 && (isSafeUseOfBitCastedAllocation(C, AI) ? 3 : 0);
   if (!isa(User)) return 0;
 
   GetElementPtrInst *GEPI = cast(User);
@@ -352,6 +364,145 @@
   return isSafeElementUse(GEPI);
 }
 
+/// isSafeUseOfBitCastedAllocation - Return true if all users of this bitcast
+/// are 
+bool SROA::isSafeUseOfBitCastedAllocation(BitCastInst *BC, AllocationInst *AI) 
{
+  for (Value::use_iterator UI = BC->use_begin(), E = BC->use_end();
+   UI != E; ++UI) {
+if (BitCastInst *BCU = dyn_cast(UI)) {
+  if (!isSafeUseOfBitCastedAllocation(BCU, AI)) 
+return false;
+} else if (MemIntrinsic *MI = dyn_cast(UI)) {
+  // If not constant length, give up.
+  ConstantInt *Length = dyn_cast(MI->getLength());
+  if (!Length) return false;
+
+  // If not the whole aggregate, give up.
+  const TargetData &TD = getAnalysis();
+  if (Length->getZExtValue() != 
+  TD.getTypeSize(AI->getType()->getElementType()))
+return false;
+  
+  // We only know about memcpy/memset/memmove.
+  if (!isa(MI) && !isa(MI) &&
+  !isa(MI))
+return false;
+  // Otherwise, we can transform it.
+} else {
+  return false;
+}
+  }
+  return true;
+}
+
+/// RewriteBitCastUserOfAlloca - BCInst (transitively) casts AI.  Transform
+/// users of the cast to use the new values instead.
+void SROA::RewriteBitCastUserOfAlloca(BitCastInst *BCInst, AllocationInst *AI,
+  SmallVector &NewElts) {
+  Constant *Zero = Constant::getNullValue(Type::Int32Ty);
+  const TargetData &TD = getAnalysis();
+  while (!BCInst->use_empty()) {
+if (BitCastInst *BCU = dyn_cast(BCInst->use_back())) {
+  RewriteBitCastUserOfAlloca(BCU, AI, NewElts);
+  continue;
+}
+
+// Otherwise, must be memcpy/memmove/memset of the entire aggregate.  Split
+// into one per element.