[llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/store_op_load_fold2.ll

2006-10-22 Thread Evan Cheng


Changes in directory llvm/test/Regression/CodeGen/X86:

store_op_load_fold2.ll updated: 1.4 -> 1.5
---
Log message:

Fix test case.

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

 store_op_load_fold2.ll |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)


Index: llvm/test/Regression/CodeGen/X86/store_op_load_fold2.ll
diff -u llvm/test/Regression/CodeGen/X86/store_op_load_fold2.ll:1.4 
llvm/test/Regression/CodeGen/X86/store_op_load_fold2.ll:1.5
--- llvm/test/Regression/CodeGen/X86/store_op_load_fold2.ll:1.4 Tue Aug 29 
16:49:58 2006
+++ llvm/test/Regression/CodeGen/X86/store_op_load_fold2.ll Mon Oct 23 
00:11:09 2006
@@ -9,21 +9,18 @@
 
 internal fastcc int %dct_chroma(int %uv, int %cr_cbp) {
 entry:
-   br bool false, label %bb2611, label %cond_true129
+   br bool true, label %cond_true2732.preheader, label %cond_true129
 
 cond_true129:  ; preds = %entry
ret int 0
 
-bb2611:; preds = %entry
-   br bool false, label %cond_true2732.preheader, label %cond_next2752
-
 cond_true2732.preheader:   ; preds = %bb2611
%tmp2666 = getelementptr %struct.Macroblock* null, int 0, uint 13   
;  [#uses=2]
%tmp2674 = cast int 0 to ubyte  ;  [#uses=1]
-   br bool false, label %cond_true2732.preheader.split.us, label 
%cond_true2732.preheader.split
+   br bool true, label %cond_true2732.preheader.split.us, label 
%cond_true2732.preheader.split
 
 cond_true2732.preheader.split.us:  ; preds = 
%cond_true2732.preheader
-   br bool false, label %cond_true2732.outer.us.us, label 
%cond_true2732.outer.us
+   br bool true, label %cond_true2732.outer.us.us, label 
%cond_true2732.outer.us
 
 cond_true2732.outer.us.us: ; preds = 
%cond_true2732.preheader.split.us
%tmp2667.us.us = load long* %tmp2666;  [#uses=1]



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


[llvm-commits] [llvm-gcc4] DIV -> U/S/FDIV Patch For Review

2006-10-22 Thread Reid Spencer
Attached is a patch to llvm-gcc4, svn rev 187, that causes llvm-gcc4 to
emit UDiv, SDiv, and FDiv instructions per the change in llvm.

Reid.

Index: gcc/llvm-convert.cpp
===
--- gcc/llvm-convert.cpp	(revision 187)
+++ gcc/llvm-convert.cpp	(working copy)
@@ -544,9 +544,15 @@
   case PLUS_EXPR:  Result = EmitBinOp(exp, DestLoc, Instruction::Add);break;
   case MINUS_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Sub);break;
   case MULT_EXPR:  Result = EmitBinOp(exp, DestLoc, Instruction::Mul);break;
-  case TRUNC_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;
-  case EXACT_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;
-  case RDIV_EXPR:  Result = EmitBinOp(exp, DestLoc, Instruction::Div);break;
+  case TRUNC_DIV_EXPR: 
+Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
+break;
+  case EXACT_DIV_EXPR: 
+Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
+break;
+  case RDIV_EXPR:  
+Result = EmitBinOp(exp, DestLoc, Instruction::FDiv);
+break;
   case TRUNC_MOD_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Rem);break;
   case BIT_AND_EXPR:   Result = EmitBinOp(exp, DestLoc, Instruction::And);break;
   case BIT_IOR_EXPR:   Result = EmitBinOp(exp, DestLoc, Instruction::Or );break;
@@ -2263,6 +2269,16 @@
   // everything to the result type.
   LHS = NOOPCastToType(LHS, Ty);
   RHS = NOOPCastToType(RHS, Ty);
+
+  // Deal with signed binary operators here
+  switch (Opc) {
+default:
+  break; // no changes
+case Instruction::UDiv:
+  if (Ty->isSigned())
+Opc = Instruction::SDiv;
+  break;
+  }
   return BinaryOperator::create((Instruction::BinaryOps)Opc, LHS, RHS,
 "tmp", CurBB);
 }
@@ -3584,12 +3600,12 @@
 Value *Tmp4 = BinaryOperator::createMul(RHSr, RHSr, "tmp", CurBB); // c*c
 Value *Tmp5 = BinaryOperator::createMul(RHSi, RHSi, "tmp", CurBB); // d*d
 Value *Tmp6 = BinaryOperator::createAdd(Tmp4, Tmp5, "tmp", CurBB); // cc+dd
-DSTr = BinaryOperator::createDiv(Tmp3, Tmp6, "tmp", CurBB);
+DSTr = BinaryOperator::createFDiv(Tmp3, Tmp6, "tmp", CurBB);
 
 Value *Tmp7 = BinaryOperator::createMul(LHSi, RHSr, "tmp", CurBB); // b*c
 Value *Tmp8 = BinaryOperator::createMul(LHSr, RHSi, "tmp", CurBB); // a*d
 Value *Tmp9 = BinaryOperator::createSub(Tmp7, Tmp8, "tmp", CurBB); // bc-ad
-DSTi = BinaryOperator::createDiv(Tmp9, Tmp6, "tmp", CurBB);
+DSTi = BinaryOperator::createFDiv(Tmp9, Tmp6, "tmp", CurBB);
 break;
   }
   case EQ_EXPR:   // (a+ib) == (c+id) = (a == c) & (b == d)
Index: gcc/config/i386/i386.h
===
--- gcc/config/i386/i386.h	(revision 187)
+++ gcc/config/i386/i386.h	(working copy)
@@ -4195,7 +4195,7 @@
   }   \
   case IX86_BUILTIN_DIVPS:\
   case IX86_BUILTIN_DIVPD:\
-RESULT = BinaryOperator::createDiv(OPS[0], OPS[1], "tmp", CURBB); \
+RESULT = BinaryOperator::createFDiv(OPS[0], OPS[1], "tmp", CURBB);  \
 return true;  \
   case IX86_BUILTIN_PAND128:  \
 RESULT = BinaryOperator::createAnd(OPS[0], OPS[1], "tmp", CURBB); \
___
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/PredicateSimplifier.cpp

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.24 -> 1.25
---
Log message:

Remove the Backwards operation. Resolving now works at the time when a 
property is added by running through the list of uses of the value and
adding resolved properties to the property set.


---
Diffs of the changes:  (+102 -90)

 PredicateSimplifier.cpp |  192 +---
 1 files changed, 102 insertions(+), 90 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.24 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.25
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.24 Sun Oct 22 
17:22:58 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Sun Oct 22 20:56:02 2006
@@ -41,6 +41,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/InstVisitor.h"
 #include 
+#include 
 using namespace llvm;
 
 typedef DominatorTree::Node DTNodeType;
@@ -74,14 +75,14 @@
   return leaders.empty();
 }
 
-iterator findLeader(ElemTy e) {
+iterator findLeader(ElemTy &e) {
   typename std::map::iterator MI = mapping.find(e);
   if (MI == mapping.end()) return 0;
 
   return MI->second;
 }
 
-const_iterator findLeader(ElemTy e) const {
+const_iterator findLeader(ElemTy &e) const {
   typename std::map::const_iterator MI =
   mapping.find(e);
   if (MI == mapping.end()) return 0;
@@ -116,6 +117,11 @@
 
 // Mutators
 
+void remove(ElemTy &e) {
+  ElemTy E = e;  // The parameter to erase must not be a reference to
+  mapping.erase(E);  // an element contained in the map.
+}
+
 /// Combine two sets referring to the same element, inserting the
 /// elements as needed. Returns a valid iterator iff two already
 /// existing disjoint synonym sets were combined. The iterator
@@ -124,7 +130,7 @@
 
 /// Returns an iterator pointing to the synonym set containing
 /// element e. If none exists, a new one is created and returned.
-iterator findOrInsert(ElemTy e) {
+iterator findOrInsert(ElemTy &e) {
   iterator I = findLeader(e);
   if (I) return I;
 
@@ -203,6 +209,19 @@
   return union_find.empty();
 }
 
+void remove(Value *V) {
+  SynonymIterator I = union_find.findLeader(V);
+  if (!I) return;
+
+  union_find.remove(V);
+
+  for (PropertyIterator PI = Properties.begin(), PE = Properties.end();
+   PI != PE;) {
+Property &P = *PI++;
+if (P.I1 == I || P.I2 == I) Properties.erase(PI);
+  }
+}
+
 void addEqual(Value *V1, Value *V2) {
   // If %x = 0. and %y = -0., seteq %x, %y is true, but
   // copysign(%x) is not the same as copysign(%y).
@@ -211,6 +230,10 @@
   order(V1, V2);
   if (isa(V2)) return; // refuse to set false == true.
 
+  if (union_find.findLeader(V1) &&
+  union_find.findLeader(V1) == union_find.findLeader(V2))
+return; // no-op
+
   SynonymIterator deleted = union_find.unionSets(V1, V2);
   if (deleted) {
 SynonymIterator replacement = union_find.findLeader(V1);
@@ -234,7 +257,7 @@
   if (isa(V1) && isa(V2)) return;
 
   if (findProperty(NE, V1, V2) != Properties.end())
-return; // found.
+return; // no-op.
 
   // Add the property.
   SynonymIterator I1 = union_find.findOrInsert(V1),
@@ -308,6 +331,73 @@
   }
 }
 
+void addToResolve(Value *V, std::list &WorkList) {
+  if (!isa(V) && !isa(V)) {
+for (Value::use_iterator UI = V->use_begin(), UE = V->use_end();
+ UI != UE; ++UI) {
+  if (!isa(*UI) && !isa(*UI)) {
+WorkList.push_back(*UI);
+  }
+}
+  }
+}
+
+void resolve(std::list &WorkList) {
+  if (WorkList.empty()) return;
+
+  Value *V = WorkList.front();
+  WorkList.pop_front();
+
+  if (empty()) return;
+
+  Instruction *I = dyn_cast(V);
+  if (!I) return;
+
+  if (BinaryOperator *BO = dyn_cast(I)) {
+Value *lhs = canonicalize(BO->getOperand(0)),
+  *rhs = canonicalize(BO->getOperand(1));
+
+ConstantIntegral *CI1 = dyn_cast(lhs),
+ *CI2 = dyn_cast(rhs);
+
+if (CI1 && CI2) {
+  addToResolve(BO, WorkList);
+  addEqual(BO, ConstantExpr::get(BO->getOpcode(), CI1, CI2));
+} else if (SetCondInst *SCI = dyn_cast(BO)) {
+  PropertySet::ConstPropertyIterator NE =
+ findProperty(PropertySet::NE, lhs, rhs);
+
+  if (NE != Properties.end()) {
+switch (SCI->getOpcode()) {
+case Instruction::SetEQ:
+  addToResolve(SCI, WorkList);
+  addEqual(SCI, ConstantBool::getFalse());
+  break;
+case Instruction::SetNE:
+  addToResolve(SCI, WorkList);
+  addEqual(SCI, ConstantBool::getTrue());
+  bre

[llvm-commits] [SignlessTypes] CVS: llvm/lib/AsmParser/llvmAsmParser.y

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.266.2.6 -> 1.266.2.7
---
Log message:

Improve documentation for the opcode conversion function.


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

 llvmAsmParser.y |8 +++-
 1 files changed, 7 insertions(+), 1 deletion(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.266.2.6 
llvm/lib/AsmParser/llvmAsmParser.y:1.266.2.7
--- llvm/lib/AsmParser/llvmAsmParser.y:1.266.2.6Sun Oct 22 03:59:00 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y  Sun Oct 22 18:26:26 2006
@@ -813,7 +813,13 @@
   return Ty;
 }
 
-// This function is
+// This template function is used to obtain the correct opcode for an 
+// instruction when an obsolete opcode is encountered. The OpcodeInfo template
+// keeps track of the opcode and the "obsolete" flag. These are generated by
+// the lexer and obsolete will be true when the lexer encounters the token for
+// an obsolete opcode. For example, "div" was replaced by [usf]div but we need
+// to maintain backwards compatibility for asm files that still have the "div"
+// instruction. This function handles converting div -> [usf]div appropriately.
 template 
 static void sanitizeOpCode(OpcodeInfo &OI, const PATypeHolder& Ty) {
   if (OI.obsolete) {



___
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

2006-10-22 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.292 -> 1.293
---
Log message:

disable this code for now, it's not yet safely updating phi nodes


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

 SelectionDAGISel.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.292 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.293
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.292Sun Oct 22 
16:36:53 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Sun Oct 22 17:47:10 2006
@@ -873,8 +873,8 @@
   Reloc = DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, PTy);
 else
   Reloc = TAB;
-ADD = DAG.getNode(ISD::ADD, PTy,
-((PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD), 
Reloc);
+ADD = (PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD;
+ADD = DAG.getNode(ISD::ADD, PTy, ADD, Reloc);
 DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), ADD));
   } else {
 DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), LD));
@@ -930,7 +930,7 @@
   
   // If the switch has few cases (two or less) emit a series of specific
   // tests.
-  if (Cases.size() < 3) {
+  if (0 && Cases.size() < 3) {
 // TODO: If any two of the cases has the same destination, and if one value
 // is the same as the other, but has one bit unset that the other has set,
 // use bit manipulation to do two compares at once.  For example:



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


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

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.520.2.7 -> 1.520.2.8
---
Log message:

Don't try to replicate integer transforms/folding for floating point values.
Its not valid!


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

 InstructionCombining.cpp |   40 
 1 files changed, 4 insertions(+), 36 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.7 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.8
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.7   Sun Oct 
22 03:59:00 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Oct 22 18:27:20 2006
@@ -1983,7 +1983,7 @@
   // 0 - (X sdiv C)  -> (X sdiv -C)
   if (Op1I->getOpcode() == Instruction::SDiv)
 if (ConstantInt *CSI = dyn_cast(Op0))
-  if (CSI->isNullValue() && CSI->getType()->isSigned())
+  if (CSI->getType()->isSigned() && CSI->isNullValue())
 if (Constant *DivRHS = dyn_cast(Op1I->getOperand(1)))
   return BinaryOperator::createSDiv(Op1I->getOperand(0),
ConstantExpr::getNeg(DivRHS));
@@ -2356,39 +2356,6 @@
   if (common)
 return common;
 
-  // If right hand side is a constant floating point ...
-  if (ConstantFP *RHS = dyn_cast(Op1)) {
-// div X, 1 == X
-if (RHS->isExactlyValue(1.0))
-  return ReplaceInstUsesWith(I, Op0);
-
-// div X, -1 == -X
-if (RHS->isExactlyValue(-1.0))
-  return BinaryOperator::createNeg(Op0);
-
-// (X / C1) / C2  -> X / (C1*C2)
-if (Instruction *LHS = dyn_cast(Op0))
-  if (LHS->getOpcode()==Instruction::FDiv)
-if (ConstantFP *LHSRHS = dyn_cast(LHS->getOperand(1))) {
-  return BinaryOperator::create(Instruction::FDiv, LHS->getOperand(0),
-  ConstantExpr::getMul(RHS, LHSRHS));
-}
-
-if (!RHS->isNullValue()) { // avoid X fdiv 0
-  if (SelectInst *SI = dyn_cast(Op0))
-if (Instruction *R = FoldOpIntoSelect(I, SI, this))
-  return R;
-  if (isa(Op0))
-if (Instruction *NV = FoldOpIntoPhi(I))
-  return NV;
-}
-  }
-
-  // 0 / X == 0
-  if (ConstantFP *LHS = dyn_cast(Op0))
-if (LHS->isExactlyValue(0))
-  return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
-
   // Handle div X, Cond?Y:Z
   if (SelectInst *SI = dyn_cast(Op1)) {
 // div X, (Cond ? 0 : Y) -> div X, Y.  If the div and the select are in the
@@ -3838,7 +3805,9 @@
 static bool MulWithOverflow(ConstantInt *&Result, ConstantInt *In1,
 ConstantInt *In2) {
   Result = cast(ConstantExpr::getMul(In1, In2));
-  return !In2->isNullValue() && ConstantExpr::getSDiv(Result, In2) != In1;
+  return !In2->isNullValue() && (In2->getType()->isSigned() ? 
+ ConstantExpr::getSDiv(Result, In2) :
+ ConstantExpr::getUDiv(Result, In2)) != In1;
 }
 
 static bool isPositive(ConstantInt *C) {
@@ -4497,7 +4466,6 @@
 
   case Instruction::SDiv:
   case Instruction::UDiv:
-  case Instruction::FDiv:
 // Fold: (div X, C1) op C2 -> range check
 if (ConstantInt *DivRHS = dyn_cast(LHSI->getOperand(1))) {
   // Fold this div into the comparison, producing a range check.



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

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.22 -> 1.23
---
Log message:

Whoops! Add missing NULL check.


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

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


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.22 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.23
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.22 Sun Oct 22 
16:36:41 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Sun Oct 22 16:38:24 2006
@@ -350,6 +350,7 @@
 } break;
 case Instruction::Xor: {
   ConstantIntegral *CI = dyn_cast(V1);
+ if (!CI) break;
   if (CI->isAllOnesValue()) {
 if (BO->getOperand(0) == V1)
   add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false);



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


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

2006-10-22 Thread Anton Korobeynikov


Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.203 -> 1.204
---
Log message:

Do section switching right way for Mingw\Cygwin and Linux.
This will allow (after llvm-gcc linkage fix) more dummy tests using 
libstdc++ to pass on mingw :)


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

 X86AsmPrinter.cpp |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.203 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.204
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.203 Wed Oct 18 04:12:29 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Sun Oct 22 16:37:13 2006
@@ -180,12 +180,18 @@
 << "\t.weak_definition " << name << "\n";
   SwitchToDataSection(".section __DATA,__const_coal,coalesced", I);
 } else if (Subtarget->isTargetCygwin()) {
-  O << "\t.section\t.data$linkonce." << name << ",\"aw\"\n"
-<< "\t.globl " << name << "\n"
+  std::string SectionName(".section\t.data$linkonce." +
+  name +
+  ",\"aw\"\n");
+  SwitchToDataSection(SectionName.c_str(), I);
+  O << "\t.globl " << name << "\n"
 << "\t.linkonce same_size\n";
 } else {
-  O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n"
-<< "\t.weak " << name << "\n";
+  std::string SectionName("\t.section\t.llvm.linkonce.d." +
+  name +
+  ",\"aw\",@progbits\n");
+  SwitchToDataSection(SectionName.c_str(), I);
+  O << "\t.weak " << name << "\n";
 }
 break;
   case GlobalValue::AppendingLinkage:



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


[llvm-commits] CVS: llvm/lib/Target/X86/README.txt

2006-10-22 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

README.txt updated: 1.142 -> 1.143
---
Log message:

this part implemented.


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

 README.txt |   29 -
 1 files changed, 29 deletions(-)


Index: llvm/lib/Target/X86/README.txt
diff -u llvm/lib/Target/X86/README.txt:1.142 
llvm/lib/Target/X86/README.txt:1.143
--- llvm/lib/Target/X86/README.txt:1.142Thu Oct 12 17:01:26 2006
+++ llvm/lib/Target/X86/README.txt  Sun Oct 22 16:40:12 2006
@@ -607,35 +607,6 @@
 cmp eax, 6
 jz label
 
-If we aren't going to do this, we should lower the switch better.  We compile 
-the code to:
-
-_f:
-movl 8(%esp), %eax
-movl 4(%esp), %ecx
-cmpl $6, %ecx
-jl LBB1_4   #entry
-jmp LBB1_3  #entry
-LBB1_3: #entry
-cmpl $6, %ecx
-je LBB1_1   #bb
-jmp LBB1_2  #UnifiedReturnBlock
-LBB1_4: #entry
-cmpl $4, %ecx
-jne LBB1_2  #UnifiedReturnBlock
-LBB1_1: #bb
-incl %eax
-ret
-LBB1_2: #UnifiedReturnBlock
-ret
-
-In the code above, the 'if' is turned into a 'switch' at the mid-level.  It
-looks  like the 'lower to branches' mode could be improved a little here.  In
-particular, the fall-through to LBB1_3 doesn't need a branch.  It would also be
-nice to eliminate the redundant "cmp 6", maybe by lowering to a linear sequence
-of compares if there are below a certain number of cases (instead of a binary
-sequence)?
-
 //===-===//
 
 GCC's ix86_expand_int_movcc function (in i386.c) has a ton of interesting



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


[llvm-commits] CVS: llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/test/Regression/Transforms/PredicateSimplifier:

2006-10-22-IntOr.ll added (r1.1)
---
Log message:

Handle "if ((x|y) != 0)" for ints like we do for bools. Fixes missed
optimization opportunity pointed out by Chris Lattner.


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

 2006-10-22-IntOr.ll |   21 +
 1 files changed, 21 insertions(+)


Index: llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll
diff -c /dev/null 
llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll:1.1
*** /dev/null   Sun Oct 22 16:36:51 2006
--- llvm/test/Regression/Transforms/PredicateSimplifier/2006-10-22-IntOr.ll 
Sun Oct 22 16:36:41 2006
***
*** 0 
--- 1,21 
+ ; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis 
| grep -v declare | not grep fail
+ 
+ int %f(int %x, int %y) {
+ entry:
+   %tmp2 = or int %x, %y   ;  [#uses=1]
+   %tmp = setne int %tmp2, 0   ;  [#uses=1]
+   br bool %tmp, label %cond_true, label %return
+ 
+ cond_true:; preds = %entry
+   %tmp4 = seteq int %x, 0 ;  [#uses=1]
+   br bool %tmp4, label %cond_true5, label %return
+ 
+ cond_true5:   ; preds = %cond_true
+   %tmp6 = call int %fail( )   ;  [#uses=0]
+   ret int %tmp6
+ 
+ return:   ; preds = %cond_next7
+   ret int 0
+ }
+ 
+ declare int %fail()



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


[llvm-commits] [SignlessTypes] CVS: llvm/lib/VMCore/ConstantFolding.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.93.2.6 -> 1.93.2.7
---
Log message:

Don't try to replicate integer transforms/folding for floating point values.
Its not valid!


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

 ConstantFolding.cpp |5 -
 1 files changed, 5 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.6 
llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.7
--- llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.6Sun Oct 22 03:59:01 2006
+++ llvm/lib/VMCore/ConstantFolding.cpp Sun Oct 22 18:27:21 2006
@@ -1396,11 +1396,6 @@
   if (CI->getZExtValue() == 1)
 return const_cast(V1); // X / 1 == X
 break;
-  case Instruction::FDiv:
-if (const ConstantFP* CFP = dyn_cast(V2)) // X / 1.0 
== X
-  if (CFP->getValue() == 1.0)
-return const_cast(V1);
-break;
   case Instruction::Rem:
 if (const ConstantInt *CI = dyn_cast(V2))
   if (CI->getZExtValue() == 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/SelectionDAGISel.cpp

2006-10-22 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.293 -> 1.294
---
Log message:

Fix phi node updating for switches lowered to linear sequences of branches.


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

 SelectionDAGISel.cpp |   14 +-
 1 files changed, 13 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.293 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.294
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.293Sun Oct 22 
17:47:10 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Sun Oct 22 18:00:53 2006
@@ -930,7 +930,7 @@
   
   // If the switch has few cases (two or less) emit a series of specific
   // tests.
-  if (0 && Cases.size() < 3) {
+  if (Cases.size() < 3) {
 // TODO: If any two of the cases has the same destination, and if one value
 // is the same as the other, but has one bit unset that the other has set,
 // use bit manipulation to do two compares at once.  For example:
@@ -3689,6 +3689,18 @@
 return;
   }
   
+  // If the switch block involved a branch to one of the actual successors, we
+  // need to update PHI nodes in that block.
+  for (unsigned i = 0, e = PHINodesToUpdate.size(); i != e; ++i) {
+MachineInstr *PHI = PHINodesToUpdate[i].first;
+assert(PHI->getOpcode() == TargetInstrInfo::PHI &&
+   "This is not a machine PHI node that we are updating!");
+if (BB->isSuccessor(PHI->getParent())) {
+  PHI->addRegOperand(PHINodesToUpdate[i].second, false);
+  PHI->addMachineBasicBlockOperand(BB);
+}
+  }
+  
   // If we generated any switch lowering information, build and codegen any
   // additional DAGs necessary.
   for (unsigned i = 0, e = SwitchCases.size(); i != e; ++i) {



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


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

2006-10-22 Thread Reid Spencer
Nick,
...

On Sun, 2006-10-22 at 16:38 -0500, Nick Lewycky wrote:
> 
> Changes in directory llvm/lib/Transforms/Scalar:
> 
> PredicateSimplifier.cpp updated: 1.22 -> 1.23
> ---
> Log message:
> 
> Whoops! Add missing NULL check.
> 
> 
> ---
> Diffs of the changes:  (+1 -0)
> 
>  PredicateSimplifier.cpp |1 +
>  1 files changed, 1 insertion(+)
> 
> 
> Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
> diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.22 
> llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.23
> --- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.22   Sun Oct 22 
> 16:36:41 2006
> +++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cppSun Oct 22 
> 16:38:24 2006
> @@ -350,6 +350,7 @@
>  } break;
>  case Instruction::Xor: {
>ConstantIntegral *CI = dyn_cast(V1);
> +   if (!CI) break;

The idiom we use throughout LLVM is ..
 if (ConstantIntegral *CI = dyn_cast(V1)) 
   if (CI->isAllOnesValue()) {
 ...
   }
 break;

Which is equivalent to what you wrote but a little cleaner.

>if (CI->isAllOnesValue()) {
>  if (BO->getOperand(0) == V1)
>add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), 
> false);
> 
> 
> 
> ___
> 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] [SignlessTypes] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Reader.h

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.198.2.5 -> 1.198.2.6
Reader.h updated: 1.34.2.1 -> 1.34.2.2
---
Log message:

Improve documentation on opcode upgrade from obsolete versions. Fully
document all opcodes. Don't try to jump the gun on REM conversions.


---
Diffs of the changes:  (+53 -32)

 Reader.cpp |   77 +++--
 Reader.h   |8 ++
 2 files changed, 53 insertions(+), 32 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.5 
llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.6
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.5   Sun Oct 22 03:59:00 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Oct 22 18:28:40 2006
@@ -595,11 +595,12 @@
 return Result;
 
   // We're dealing with an upgrade situation. For each of the opcode values,
-  // perform the necessary convertion.
+  // perform the necessary conversion.
   switch (Opcode) {
 default: // Pass Through
   // If we don't match any of the cases here then the opcode is fine the
-  // way it is.
+  // way it is. That will happen for the opcodes > 53 which are the
+  // volatile load/store, and call/invoke with calling conventions.
   break;
 case 1: // Ret
   Opcode = Instruction::Ret;
@@ -630,9 +631,9 @@
   break;
 case 10: // Div 
   // The type of the instruction is based on the operands. We need to 
select
-  // either udiv or sdiv based on that type. This expression selects the
-  // cases where the type is floating point or signed in which case we
-  // generated an sdiv instruction.
+  // fdiv, udiv or sdiv based on that type. The iType values are hardcoded
+  // to the values used in bytecode version 5 (and prior) because it is
+  // likely these codes will change in future versions of LLVM.
   if (iType == 10 || iType == 11 )
 Opcode = Instruction::FDiv;
   else if (iType >= 2 && iType <= 9 && iType % 2 != 0)
@@ -642,16 +643,8 @@
   break;
 
 case 11: // Rem
-  // As with "Div", make the signed/unsigned Rem instruction choice based
-  // on the type of the instruction.
-  if (iType == 10 || iType == 11)
-Opcode = Instruction::Rem;
-  else if (iType >= 2 && iType <= 9 && iType % 2 != 0)
-Opcode = Instruction::Rem;
-  else
 Opcode = Instruction::Rem;
   break;
-
 case 12: // And
   Opcode = Instruction::And;
   break;
@@ -717,12 +710,17 @@
   Function* NF = TheModule->getOrInsertFunction(
 "llvm.va_copy", ArgTy, ArgTy, (Type *)0);
 
-  //b = vanext a, t ->
-  //foo = alloca 1 of t
-  //bar = vacopy a
-  //store bar -> foo
-  //tmp = vaarg foo, t
-  //b = load foo
+  // In llvm 1.6 the VANext instruction was dropped because it was only 
+  // necessary to have a VAArg instruction. The code below transforms an
+  // old vanext instruction into the equivalent code given only the 
+  // availability of the new vaarg instruction. Essentially, the transform
+  // is as follows:
+  //b = vanext a, t ->
+  //foo = alloca 1 of t
+  //bar = vacopy a
+  //store bar -> foo
+  //tmp = vaarg foo, t
+  //b = load foo
   AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
   BB->getInstList().push_back(foo);
   CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0]));
@@ -738,11 +736,15 @@
   Function* NF = TheModule->getOrInsertFunction(
 "llvm.va_copy", ArgTy, ArgTy, (Type *)0);
 
-  //b = vaarg a, t ->
-  //foo = alloca 1 of t
-  //bar = vacopy a
-  //store bar -> foo
-  //b = vaarg foo, t
+  // In llvm 1.6 the VAArg's instruction semantics were changed.  The code 
+  // below transforms an old vaarg instruction into the equivalent code 
+  // given only the availability of the new vaarg instruction. Essentially,
+  // the transform is as follows:
+  //b = vaarg a, t ->
+  //foo = alloca 1 of t
+  //bar = vacopy a
+  //store bar -> foo
+  //b = vaarg foo, t
   AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
   BB->getInstList().push_back(foo);
   CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0]));
@@ -772,8 +774,20 @@
 case 40: // ShuffleVector
   Opcode = Instruction::ShuffleVector;
   break;
+case 56: // Invoke with encoded CC
+case 57: // Invoke Fast CC
+case 58: // Call with extra operand for calling conv
+case 59: // tail call, Fast CC
+case 60: // normal call, Fast CC
+case 61: // tail call, C Calling Conv
+case 62: // volatile load
+case 63: // volatile store
+  // In all these cases, we pass the opcode through. The new version uses
+  // the same code (for now, this might change in 2.0). These are listed
+  // here to document the opcodes in use in vers 

[llvm-commits] CVS: llvm-test/MultiSource/Applications/JM/ldecod/Makefile

2006-10-22 Thread Reid Spencer


Changes in directory llvm-test/MultiSource/Applications/JM/ldecod:

Makefile updated: 1.3 -> 1.4
---
Log message:

Oops. FP_TOLERANCE should be 0.02 not 0.2.


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

 Makefile |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm-test/MultiSource/Applications/JM/ldecod/Makefile
diff -u llvm-test/MultiSource/Applications/JM/ldecod/Makefile:1.3 
llvm-test/MultiSource/Applications/JM/ldecod/Makefile:1.4
--- llvm-test/MultiSource/Applications/JM/ldecod/Makefile:1.3   Sun Oct 22 
14:09:58 2006
+++ llvm-test/MultiSource/Applications/JM/ldecod/Makefile   Sun Oct 22 
15:01:10 2006
@@ -2,7 +2,7 @@
 PROG = ldecod
 CPPFLAGS = -D __USE_LARGEFILE64 -D _FILE_OFFSET_BITS=64
 LDFLAGS  = -lm $(TOOLLINKOPTS)
-FP_TOLERANCE = 0.2
+FP_TOLERANCE = 0.02
 
 RUN_OPTIONS = -i $(PROJ_SRC_DIR)/data/test.264 -o 
$(PROJ_SRC_DIR)/data/test_dec.yuv -r $(PROJ_SRC_DIR)/data/test_rec.yuv
 



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

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.23 -> 1.24
---
Log message:

Fix similar missing optimization opportunity in XOR.


---
Diffs of the changes:  (+22 -13)

 PredicateSimplifier.cpp |   35 ++-
 1 files changed, 22 insertions(+), 13 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.23 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.24
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.23 Sun Oct 22 
16:38:24 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Sun Oct 22 17:22:58 2006
@@ -349,19 +349,28 @@
   }
 } break;
 case Instruction::Xor: {
-  ConstantIntegral *CI = dyn_cast(V1);
- if (!CI) break;
-  if (CI->isAllOnesValue()) {
-if (BO->getOperand(0) == V1)
-  add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false);
-if (BO->getOperand(1) == V1)
-  add(Opcode, ConstantBool::getFalse(), BO->getOperand(0), false);
-  }
-  if (CI->isNullValue()) {
-if (BO->getOperand(0) == ConstantBool::getTrue())
-  add(Opcode, ConstantBool::getTrue(), BO->getOperand(1), false);
-if (BO->getOperand(1) == ConstantBool::getTrue())
-  add(Opcode, ConstantBool::getTrue(), BO->getOperand(0), false);
+  if (ConstantIntegral *CI = dyn_cast(V1)) {
+const Type *Ty = BO->getType();
+if (CI->isAllOnesValue()) {
+  if (BO->getOperand(0) == V1)
+add(Opcode, Constant::getNullValue(Ty),
+BO->getOperand(1), false);
+  if (BO->getOperand(1) == V1)
+add(Opcode, Constant::getNullValue(Ty),
+BO->getOperand(0), false);
+}
+if (CI->isNullValue()) {
+  ConstantIntegral *Op0 =
+  dyn_cast(BO->getOperand(0));
+  ConstantIntegral *Op1 =
+  dyn_cast(BO->getOperand(1));
+  if (Op0 && Op0->isAllOnesValue())
+add(Opcode, ConstantIntegral::getAllOnesValue(Ty),
+BO->getOperand(1), false);
+  if (Op1 && Op1->isAllOnesValue())
+add(Opcode, ConstantIntegral::getAllOnesValue(Ty),
+BO->getOperand(0), false);
+}
   }
 } break;
 default:



___
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

2006-10-22 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.291 -> 1.292
---
Log message:

Implement PR964: http://llvm.org/PR964  and 
Regression/CodeGen/Generic/SwitchLowering.ll


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

 SelectionDAGISel.cpp |   49 -
 1 files changed, 44 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.291 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.292
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.291Fri Oct 20 
02:07:24 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Sun Oct 22 16:36:53 2006
@@ -889,18 +889,19 @@
   if (++BBI != CurMBB->getParent()->end())
 NextBlock = BBI;
   
+  MachineBasicBlock *Default = FuncInfo.MBBMap[I.getDefaultDest()];
+
   // If there is only the default destination, branch to it if it is not the
   // next basic block.  Otherwise, just fall through.
   if (I.getNumOperands() == 2) {
 // Update machine-CFG edges.
-MachineBasicBlock *DefaultMBB = FuncInfo.MBBMap[I.getDefaultDest()];
 
 // If this is not a fall-through branch, emit the branch.
-if (DefaultMBB != NextBlock)
+if (Default != NextBlock)
   DAG.setRoot(DAG.getNode(ISD::BR, MVT::Other, getRoot(),
-  DAG.getBasicBlock(DefaultMBB)));
+  DAG.getBasicBlock(Default)));
 
-CurMBB->addSuccessor(DefaultMBB);
+CurMBB->addSuccessor(Default);
 return;
   }
   
@@ -920,13 +921,51 @@
   // inserted into CaseBlock records, representing basic blocks in the binary
   // search tree.
   Value *SV = I.getOperand(0);
-  MachineBasicBlock *Default = FuncInfo.MBBMap[I.getDefaultDest()];
 
   // Get the MachineFunction which holds the current MBB.  This is used during
   // emission of jump tables, and when inserting any additional MBBs necessary
   // to represent the switch.
   MachineFunction *CurMF = CurMBB->getParent();
   const BasicBlock *LLVMBB = CurMBB->getBasicBlock();
+  
+  // If the switch has few cases (two or less) emit a series of specific
+  // tests.
+  if (Cases.size() < 3) {
+// TODO: If any two of the cases has the same destination, and if one value
+// is the same as the other, but has one bit unset that the other has set,
+// use bit manipulation to do two compares at once.  For example:
+// "if (X == 6 || X == 4)" -> "if ((X|2) == 6)"
+
+// Create a CaseBlock record representing a conditional branch to
+// the Case's target mbb if the value being switched on SV is equal
+// to C.
+MachineBasicBlock *CurBlock = CurMBB;
+for (unsigned i = 0, e = Cases.size(); i != e; ++i) {
+  MachineBasicBlock *FallThrough;
+  if (i != e-1) {
+FallThrough = new MachineBasicBlock(CurMBB->getBasicBlock());
+CurMF->getBasicBlockList().insert(BBI, FallThrough);
+  } else {
+// If the last case doesn't match, go to the default block.
+FallThrough = Default;
+  }
+  
+  SelectionDAGISel::CaseBlock CB(ISD::SETEQ, SV, Cases[i].first,
+ Cases[i].second, FallThrough, CurBlock);
+
+  // If emitting the first comparison, just call visitSwitchCase to emit 
the
+  // code into the current block.  Otherwise, push the CaseBlock onto the
+  // vector to be later processed by SDISel, and insert the node's MBB
+  // before the next MBB.
+  if (CurBlock == CurMBB)
+visitSwitchCase(CB);
+  else
+SwitchCases.push_back(CB);
+  
+  CurBlock = FallThrough;
+}
+return;
+  }
 
   // If the switch has more than 5 blocks, and at least 31.25% dense, and the 
   // target supports indirect branches, then emit a jump table rather than 



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

2006-10-22 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

TailRecursionElimination.cpp updated: 1.23 -> 1.24
---
Log message:

Add a workaround for PR962: http://llvm.org/PR962 , disabling the more 
aggressive form of this
transformation.  This speeds up a C++ app 2.25x.


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

 TailRecursionElimination.cpp |8 
 1 files changed, 8 insertions(+)


Index: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
diff -u llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.23 
llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.24
--- llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.23Sun Aug 
27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp Sun Oct 22 
13:42:26 2006
@@ -140,6 +140,14 @@
 FunctionContainsEscapingAllocas |=
   CheckForEscapingAllocas(BB, CannotTCETailMarkedCall);
   }
+  
+  /// FIXME: The code generator produces really bad code when an 'escaping
+  /// alloca' is changed from being a static alloca to being a dynamic alloca.
+  /// Until this is resolved, disable this transformation if that would ever
+  /// happen.  This bug is PR962.
+  if (FunctionContainsEscapingAllocas)
+return false;
+  
 
   // Second pass, change any tail calls to loops.
   for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)



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

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.21 -> 1.22
---
Log message:

Handle "if ((x|y) != 0)" for ints like we do for bools. Fixes missed
optimization opportunity pointed out by Chris Lattner.


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

 PredicateSimplifier.cpp |   23 +--
 1 files changed, 13 insertions(+), 10 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.21 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.22
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.21 Sun Oct 22 
14:53:27 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Sun Oct 22 16:36:41 2006
@@ -334,32 +334,35 @@
   if (V1 == ConstantBool::getFalse())
 add(Opcode, BO->getOperand(0), BO->getOperand(1), true);
   break;
-case Instruction::And:
-  if (V1 == ConstantBool::getTrue()) {
+case Instruction::And: {
+  ConstantIntegral *CI = dyn_cast(V1);
+  if (CI && CI->isAllOnesValue()) {
 add(Opcode, V1, BO->getOperand(0), false);
 add(Opcode, V1, BO->getOperand(1), false);
   }
-  break;
-case Instruction::Or:
-  if (V1 == ConstantBool::getFalse()) {
+} break;
+case Instruction::Or: {
+  ConstantIntegral *CI = dyn_cast(V1);
+  if (CI && CI->isNullValue()) {
 add(Opcode, V1, BO->getOperand(0), false);
 add(Opcode, V1, BO->getOperand(1), false);
   }
-  break;
-case Instruction::Xor:
-  if (V1 == ConstantBool::getTrue()) {
+} break;
+case Instruction::Xor: {
+  ConstantIntegral *CI = dyn_cast(V1);
+  if (CI->isAllOnesValue()) {
 if (BO->getOperand(0) == V1)
   add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false);
 if (BO->getOperand(1) == V1)
   add(Opcode, ConstantBool::getFalse(), BO->getOperand(0), false);
   }
-  if (V1 == ConstantBool::getFalse()) {
+  if (CI->isNullValue()) {
 if (BO->getOperand(0) == ConstantBool::getTrue())
   add(Opcode, ConstantBool::getTrue(), BO->getOperand(1), false);
 if (BO->getOperand(1) == ConstantBool::getTrue())
   add(Opcode, ConstantBool::getTrue(), BO->getOperand(0), false);
   }
-  break;
+} break;
 default:
   break;
 }



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


[llvm-commits] CVS: llvm/test/Regression/CodeGen/Generic/SwitchLowering.ll

2006-10-22 Thread Chris Lattner


Changes in directory llvm/test/Regression/CodeGen/Generic:

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

new testcase for PR964: http://llvm.org/PR964 


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

 SwitchLowering.ll |   27 +++
 1 files changed, 27 insertions(+)


Index: llvm/test/Regression/CodeGen/Generic/SwitchLowering.ll
diff -c /dev/null llvm/test/Regression/CodeGen/Generic/SwitchLowering.ll:1.1
*** /dev/null   Sun Oct 22 16:36:16 2006
--- llvm/test/Regression/CodeGen/Generic/SwitchLowering.ll  Sun Oct 22 
16:36:06 2006
***
*** 0 
--- 1,27 
+ ; RUN: llvm-as < %s | llc -march=x86 | grep cmp | wc -l | grep 1
+ ; PR964
+ 
+ sbyte* %FindChar(sbyte* %CurPtr) {
+ entry:
+   br label %bb
+ 
+ bb:   ; preds = %bb, %entry
+   %indvar = phi uint [ 0, %entry ], [ %indvar.next, %bb ] ; 
 [#uses=3]
+   %CurPtr_addr.0.rec = cast uint %indvar to int   ;  
[#uses=1]
+   %CurPtr_addr.0 = getelementptr sbyte* %CurPtr, uint %indvar 
;  [#uses=1]
+   %tmp = load sbyte* %CurPtr_addr.0   ;  [#uses=2]
+   %tmp2.rec = add int %CurPtr_addr.0.rec, 1   ;  
[#uses=1]
+   %tmp2 = getelementptr sbyte* %CurPtr, int %tmp2.rec ; 
 [#uses=1]
+   %indvar.next = add uint %indvar, 1  ;  [#uses=1]
+   switch sbyte %tmp, label %bb [
+sbyte 0, label %bb7
+sbyte 120, label %bb7
+   ]
+ 
+ bb7:  ; preds = %bb, %bb
+   %tmp = cast sbyte %tmp to ubyte ;  [#uses=1]
+   tail call void %foo( ubyte %tmp )
+   ret sbyte* %tmp2
+ }
+ 
+ declare void %foo(ubyte)



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


[llvm-commits] CVS: llvm/test/Regression/Transforms/PredicateSimplifier/predsimplify.ll

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/test/Regression/Transforms/PredicateSimplifier:

predsimplify.ll updated: 1.2 -> 1.3
---
Log message:

AllocaInst can't return a null pointer. Fixes missed optimization
opportunity pointed out by Andrew Lewycky.


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

 predsimplify.ll |   17 -
 1 files changed, 16 insertions(+), 1 deletion(-)


Index: llvm/test/Regression/Transforms/PredicateSimplifier/predsimplify.ll
diff -u llvm/test/Regression/Transforms/PredicateSimplifier/predsimplify.ll:1.2 
llvm/test/Regression/Transforms/PredicateSimplifier/predsimplify.ll:1.3
--- llvm/test/Regression/Transforms/PredicateSimplifier/predsimplify.ll:1.2 
Sat Sep  2 14:40:38 2006
+++ llvm/test/Regression/Transforms/PredicateSimplifier/predsimplify.ll Sun Oct 
22 14:53:27 2006
@@ -1,5 +1,5 @@
 ; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | 
grep -v declare | not grep fail &&
-; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | 
grep -v declare | grep pass | wc -l | grep 3
+; RUN: llvm-as < %s | opt -predsimplify -instcombine -simplifycfg | llvm-dis | 
grep -v declare | grep -c pass | grep 4
 
 void %test1(int %x) {
 entry:
@@ -149,6 +149,21 @@
   ret void
 }
 
+void %test10()  {
+entry:
+  %A = alloca int
+  %B = seteq int* %A, null
+  br bool %B, label %cond_true, label %cond_false
+
+cond_true:
+  call void (...)* %fail ( )
+  ret void
+
+cond_false:
+  call void (...)* %pass ( )
+  ret void
+}
+
 void %switch1(int %x) {
 entry:
   %A = seteq int %x, 10



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

2006-10-22 Thread Nick Lewycky


Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.20 -> 1.21
---
Log message:

AllocaInst can't return a null pointer. Fixes missed optimization
opportunity pointed out by Andrew Lewycky.


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

 PredicateSimplifier.cpp |6 ++
 1 files changed, 6 insertions(+)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.20 
llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.21
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.20 Wed Oct 11 
21:02:44 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp  Sun Oct 22 14:53:27 2006
@@ -31,6 +31,7 @@
 #define DEBUG_TYPE "predsimplify"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
 #include "llvm/ADT/Statistic.h"
@@ -446,6 +447,7 @@
   void visitBranchInst(BranchInst &BI);
   void visitSwitchInst(SwitchInst &SI);
 
+  void visitAllocaInst(AllocaInst &AI);
   void visitLoadInst(LoadInst &LI);
   void visitStoreInst(StoreInst &SI);
   void visitBinaryOperator(BinaryOperator &BO);
@@ -712,6 +714,10 @@
   }
 }
 
+void PredicateSimplifier::Forwards::visitAllocaInst(AllocaInst &AI) {
+  KP.addNotEqual(Constant::getNullValue(AI.getType()), &AI);
+}
+
 void PredicateSimplifier::Forwards::visitLoadInst(LoadInst &LI) {
   Value *Ptr = LI.getPointerOperand();
   KP.addNotEqual(Constant::getNullValue(Ptr->getType()), Ptr);



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


[llvm-commits] CVS: llvm-test/MultiSource/Applications/JM/ldecod/Makefile

2006-10-22 Thread Reid Spencer


Changes in directory llvm-test/MultiSource/Applications/JM/ldecod:

Makefile updated: 1.2 -> 1.3
---
Log message:

Set the FP TOLERANCE to 0.02 so the llc and cbe can pass. This is a horrid
tolerance and still doesn't cause the JIT to pass.


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

 Makefile |1 +
 1 files changed, 1 insertion(+)


Index: llvm-test/MultiSource/Applications/JM/ldecod/Makefile
diff -u llvm-test/MultiSource/Applications/JM/ldecod/Makefile:1.2 
llvm-test/MultiSource/Applications/JM/ldecod/Makefile:1.3
--- llvm-test/MultiSource/Applications/JM/ldecod/Makefile:1.2   Mon Mar  6 
12:09:38 2006
+++ llvm-test/MultiSource/Applications/JM/ldecod/Makefile   Sun Oct 22 
14:09:58 2006
@@ -2,6 +2,7 @@
 PROG = ldecod
 CPPFLAGS = -D __USE_LARGEFILE64 -D _FILE_OFFSET_BITS=64
 LDFLAGS  = -lm $(TOOLLINKOPTS)
+FP_TOLERANCE = 0.2
 
 RUN_OPTIONS = -i $(PROJ_SRC_DIR)/data/test.264 -o 
$(PROJ_SRC_DIR)/data/test_dec.yuv -r $(PROJ_SRC_DIR)/data/test_rec.yuv
 



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


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

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.273 -> 1.274
---
Log message:

Don't generate a prototype for _setjmp. At least on Linux, this function
has a different prototype than the one #included from . This
patch fixes siod and a number of other test cases on Linux that were
failing the CBE because of this _setjmp issue.


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

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


Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.273 
llvm/lib/Target/CBackend/Writer.cpp:1.274
--- llvm/lib/Target/CBackend/Writer.cpp:1.273   Fri Oct 20 02:07:24 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Sun Oct 22 04:58:21 2006
@@ -1075,8 +1075,8 @@
   
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
 // Don't print declarations for intrinsic functions.
-if (!I->getIntrinsicID() &&
-I->getName() != "setjmp" && I->getName() != "longjmp") {
+if (!I->getIntrinsicID() && I->getName() != "setjmp" && 
+I->getName() != "longjmp" && I->getName() != "_setjmp") {
   printFunctionSignature(I, true);
   if (I->hasWeakLinkage() || I->hasLinkOnceLinkage()) 
 Out << " __ATTRIBUTE_WEAK__";



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


[llvm-commits] [SignlessTypes] CVS: llvm/lib/Target/CBackend/Writer.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.272.2.4 -> 1.272.2.5
---
Log message:

Don't generate a prototype for _setjmp. At least on Linux, this function
has a different prototype than the one #included from . This 
patch fixes siod and a number of other test cases on Linux that were 
failing the CBE because of this _setjmp issue.


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

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


Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.272.2.4 
llvm/lib/Target/CBackend/Writer.cpp:1.272.2.5
--- llvm/lib/Target/CBackend/Writer.cpp:1.272.2.4   Sun Oct 22 03:59:00 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Sun Oct 22 04:55:50 2006
@@ -1079,8 +1079,8 @@
   
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
 // Don't print declarations for intrinsic functions.
-if (!I->getIntrinsicID() &&
-I->getName() != "setjmp" && I->getName() != "longjmp") {
+if (!I->getIntrinsicID() && I->getName() != "setjmp" && 
+I->getName() != "longjmp" && I->getName() != "_setjmp") {
   printFunctionSignature(I, true);
   if (I->hasWeakLinkage() || I->hasLinkOnceLinkage()) 
 Out << " __ATTRIBUTE_WEAK__";



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


[llvm-commits] [SignlessTypes] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.139.6.2 -> 1.139.6.3
---
Log message:

Implement the FDIV instruction for floating point divide.


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

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


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.2 
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.3
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.2Fri Oct 
20 03:19:49 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp  Sun Oct 22 03:59:00 2006
@@ -91,6 +91,7 @@
   CE->getOperand(0)->getType());
   case Instruction::SDiv:
   case Instruction::UDiv:
+  case Instruction::FDiv:
 return executeDivInst(getOperandValue(CE->getOperand(0), SF),
   getOperandValue(CE->getOperand(1), SF),
   CE->getOperand(0)->getType());
@@ -505,8 +506,9 @@
   case Instruction::Add:   R = executeAddInst  (Src1, Src2, Ty); break;
   case Instruction::Sub:   R = executeSubInst  (Src1, Src2, Ty); break;
   case Instruction::Mul:   R = executeMulInst  (Src1, Src2, Ty); break;
-  case Instruction::SDiv:  R = executeDivInst  (Src1, Src2, Ty); break;
-  case Instruction::UDiv:  R = executeDivInst  (Src1, Src2, Ty); break;
+  case Instruction::SDiv:  
+  case Instruction::UDiv:  
+  case Instruction::FDiv:  R = executeDivInst  (Src1, Src2, Ty); break;
   case Instruction::Rem:   R = executeRemInst  (Src1, Src2, Ty); break;
   case Instruction::And:   R = executeAndInst  (Src1, Src2, Ty); break;
   case Instruction::Or:R = executeOrInst   (Src1, Src2, Ty); break;



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


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

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.289.2.4 -> 1.289.2.5
---
Log message:

Implement the FDIV instruction for floating point divide.


---
Diffs of the changes:  (+42 -16)

 SelectionDAGISel.cpp |   58 ---
 1 files changed, 42 insertions(+), 16 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.4 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.5
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.4Fri Oct 
20 03:19:49 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Sun Oct 22 03:59:00 2006
@@ -499,24 +499,35 @@
   void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); }
   void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); }
 
-  void visitBinary(User &I, unsigned IntOp, unsigned FPOp, unsigned VecOp);
+  void visitIntBinary(User &I, unsigned IntOp, unsigned VecOp);
+  void visitFPBinary(User &I, unsigned FPOp, unsigned VecOp);
   void visitShift(User &I, unsigned Opcode);
   void visitAdd(User &I) { 
-visitBinary(I, ISD::ADD, ISD::FADD, ISD::VADD); 
+if (I.getType()->isFloatingPoint())
+  visitFPBinary(I, ISD::FADD, ISD::VADD); 
+else
+  visitIntBinary(I, ISD::ADD, ISD::VADD); 
   }
   void visitSub(User &I);
-  void visitMul(User &I) { 
-visitBinary(I, ISD::MUL, ISD::FMUL, ISD::VMUL); 
+  void visitMul(User &I) {
+if (I.getType()->isFloatingPoint()) 
+  visitFPBinary(I, ISD::FMUL, ISD::VMUL); 
+else
+  visitIntBinary(I, ISD::MUL, ISD::VMUL); 
   }
-  void visitUDiv(User &I) { visitBinary(I, ISD::UDIV, ISD::FDIV, ISD::VUDIV); }
-  void visitSDiv(User &I) { visitBinary(I, ISD::SDIV, ISD::FDIV, ISD::VSDIV); }
+  void visitUDiv(User &I) { visitIntBinary(I, ISD::UDIV, ISD::VUDIV); }
+  void visitSDiv(User &I) { visitIntBinary(I, ISD::SDIV, ISD::VSDIV); }
+  void visitFDiv(User &I) { visitFPBinary(I, ISD::FDIV,  ISD::VSDIV); }
   void visitRem(User &I) {
 const Type *Ty = I.getType();
-visitBinary(I, Ty->isSigned() ? ISD::SREM : ISD::UREM, ISD::FREM, 0);
-  }
-  void visitAnd(User &I) { visitBinary(I, ISD::AND, 0, ISD::VAND); }
-  void visitOr (User &I) { visitBinary(I, ISD::OR,  0, ISD::VOR); }
-  void visitXor(User &I) { visitBinary(I, ISD::XOR, 0, ISD::VXOR); }
+if (Ty->isFloatingPoint())
+  visitFPBinary(I, ISD::FREM, 0);
+else 
+  visitIntBinary(I, Ty->isSigned() ? ISD::SREM : ISD::UREM, 0);
+  }
+  void visitAnd(User &I) { visitIntBinary(I, ISD::AND, ISD::VAND); }
+  void visitOr (User &I) { visitIntBinary(I, ISD::OR,  ISD::VOR); }
+  void visitXor(User &I) { visitIntBinary(I, ISD::XOR, ISD::VXOR); }
   void visitShl(User &I) { visitShift(I, ISD::SHL); }
   void visitShr(User &I) { 
 visitShift(I, I.getType()->isUnsigned() ? ISD::SRL : ISD::SRA);
@@ -1091,19 +1102,34 @@
 setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
 return;
   }
-  }
-  visitBinary(I, ISD::SUB, ISD::FSUB, ISD::VSUB);
+visitFPBinary(I, ISD::FSUB, ISD::VSUB);
+  } else 
+visitIntBinary(I, ISD::SUB, ISD::VSUB);
 }
 
-void SelectionDAGLowering::visitBinary(User &I, unsigned IntOp, unsigned FPOp, 
-   unsigned VecOp) {
+void 
+SelectionDAGLowering::visitIntBinary(User &I, unsigned IntOp, unsigned VecOp) {
   const Type *Ty = I.getType();
   SDOperand Op1 = getValue(I.getOperand(0));
   SDOperand Op2 = getValue(I.getOperand(1));
 
   if (Ty->isIntegral()) {
 setValue(&I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2));
-  } else if (Ty->isFloatingPoint()) {
+  } else {
+const PackedType *PTy = cast(Ty);
+SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32);
+SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType()));
+setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
+  }
+}
+
+void 
+SelectionDAGLowering::visitFPBinary(User &I, unsigned FPOp, unsigned VecOp) {
+  const Type *Ty = I.getType();
+  SDOperand Op1 = getValue(I.getOperand(0));
+  SDOperand Op2 = getValue(I.getOperand(1));
+
+  if (Ty->isFloatingPoint()) {
 setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
   } else {
 const PackedType *PTy = cast(Ty);



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


[llvm-commits] [SignlessTypes] CVS: llvm/test/Feature/signedinst.ll

2006-10-22 Thread Reid Spencer


Changes in directory llvm/test/Feature:

signedinst.ll updated: 1.1.2.2 -> 1.1.2.3
---
Log message:

Implement the FDIV instruction for floating point divide.


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

 signedinst.ll |1 +
 1 files changed, 1 insertion(+)


Index: llvm/test/Feature/signedinst.ll
diff -u llvm/test/Feature/signedinst.ll:1.1.2.2 
llvm/test/Feature/signedinst.ll:1.1.2.3
--- llvm/test/Feature/signedinst.ll:1.1.2.2 Sat Oct 21 20:36:52 2006
+++ llvm/test/Feature/signedinst.ll Sun Oct 22 03:59:01 2006
@@ -8,5 +8,6 @@
   %d = sdiv uint 6, 3
   %c = udiv uint 4, 2
   %e = udiv int 4, -2
+  %f = fdiv double 9.0, -3.0
   ret int %a
 }



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


[llvm-commits] [SignlessTypes] CVS: llvm/tools/llvm2cpp/CppWriter.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/tools/llvm2cpp:

CppWriter.cpp updated: 1.16.2.2 -> 1.16.2.3
---
Log message:

Implement the FDIV instruction for floating point divide.


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

 CppWriter.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/tools/llvm2cpp/CppWriter.cpp
diff -u llvm/tools/llvm2cpp/CppWriter.cpp:1.16.2.2 
llvm/tools/llvm2cpp/CppWriter.cpp:1.16.2.3
--- llvm/tools/llvm2cpp/CppWriter.cpp:1.16.2.2  Fri Oct 20 03:22:22 2006
+++ llvm/tools/llvm2cpp/CppWriter.cpp   Sun Oct 22 03:59:01 2006
@@ -775,6 +775,7 @@
 case Instruction::Mul:Out << "getMul"; break;
 case Instruction::UDiv:   Out << "getUDiv"; break;
 case Instruction::SDiv:   Out << "getSDiv"; break;
+case Instruction::FDiv:   Out << "getFDiv"; break;
 case Instruction::Rem:Out << "getRem"; break;
 case Instruction::And:Out << "getAnd"; break;
 case Instruction::Or: Out << "getOr"; break;
@@ -1024,6 +1025,7 @@
 case Instruction::Mul:
 case Instruction::UDiv:
 case Instruction::SDiv:
+case Instruction::FDiv:
 case Instruction::Rem:
 case Instruction::And:
 case Instruction::Or:
@@ -1037,6 +1039,7 @@
 case Instruction::Mul: Out << "Instruction::Mul"; break;
 case Instruction::UDiv:Out << "Instruction::UDiv"; break;
 case Instruction::SDiv:Out << "Instruction::SDiv"; break;
+case Instruction::FDiv:Out << "Instruction::FDiv"; break;
 case Instruction::Rem: Out << "Instruction::Rem"; break;
 case Instruction::And: Out << "Instruction::And"; break;
 case Instruction::Or:  Out << "Instruction::Or";  break;



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


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

2006-10-22 Thread Reid Spencer


Changes in directory llvm/include/llvm/Support:

PatternMatch.h updated: 1.9.2.1 -> 1.9.2.2
---
Log message:

Implement the FDIV instruction for floating point divide.


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

 PatternMatch.h |6 ++
 1 files changed, 6 insertions(+)


Index: llvm/include/llvm/Support/PatternMatch.h
diff -u llvm/include/llvm/Support/PatternMatch.h:1.9.2.1 
llvm/include/llvm/Support/PatternMatch.h:1.9.2.2
--- llvm/include/llvm/Support/PatternMatch.h:1.9.2.1Thu Oct 19 23:27:17 2006
+++ llvm/include/llvm/Support/PatternMatch.hSun Oct 22 03:59:00 2006
@@ -124,6 +124,12 @@
 }
 
 template
+inline BinaryOp_match m_FDiv(const LHS &L,
+const RHS &R) {
+  return BinaryOp_match(L, R);
+}
+
+template
 inline BinaryOp_match m_Rem(const LHS &L,
 const RHS &R) {
   return BinaryOp_match(L, R);



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


[llvm-commits] [SignlessTypes] CVS: llvm/include/llvm/Constants.h Instruction.def

2006-10-22 Thread Reid Spencer


Changes in directory llvm/include/llvm:

Constants.h updated: 1.88.2.6 -> 1.88.2.7
Instruction.def updated: 1.19.6.4 -> 1.19.6.5
---
Log message:

Implement the FDIV instruction for floating point divide.


---
Diffs of the changes:  (+35 -33)

 Constants.h |1 
 Instruction.def |   67 
 2 files changed, 35 insertions(+), 33 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.88.2.6 
llvm/include/llvm/Constants.h:1.88.2.7
--- llvm/include/llvm/Constants.h:1.88.2.6  Fri Oct 20 02:47:21 2006
+++ llvm/include/llvm/Constants.h   Sun Oct 22 03:58:59 2006
@@ -546,6 +546,7 @@
   static Constant *getMul(Constant *C1, Constant *C2);
   static Constant *getUDiv(Constant *C1, Constant *C2);
   static Constant *getSDiv(Constant *C1, Constant *C2);
+  static Constant *getFDiv(Constant *C1, Constant *C2);
   static Constant *getRem(Constant *C1, Constant *C2);
   static Constant *getAnd(Constant *C1, Constant *C2);
   static Constant *getOr(Constant *C1, Constant *C2);


Index: llvm/include/llvm/Instruction.def
diff -u llvm/include/llvm/Instruction.def:1.19.6.4 
llvm/include/llvm/Instruction.def:1.19.6.5
--- llvm/include/llvm/Instruction.def:1.19.6.4  Sat Oct 21 03:59:42 2006
+++ llvm/include/llvm/Instruction.def   Sun Oct 22 03:59:00 2006
@@ -95,47 +95,48 @@
 HANDLE_BINARY_INST( 9, Mul  , BinaryOperator)
 HANDLE_BINARY_INST(10, UDiv , BinaryOperator)
 HANDLE_BINARY_INST(11, SDiv , BinaryOperator)
-HANDLE_BINARY_INST(12, Rem  , BinaryOperator)
+HANDLE_BINARY_INST(12, FDiv , BinaryOperator)
+HANDLE_BINARY_INST(13, Rem  , BinaryOperator)
 
 // Logical operators...
-HANDLE_BINARY_INST(13, And   , BinaryOperator)
-HANDLE_BINARY_INST(14, Or, BinaryOperator)
-HANDLE_BINARY_INST(15, Xor   , BinaryOperator)
+HANDLE_BINARY_INST(14, And   , BinaryOperator)
+HANDLE_BINARY_INST(15, Or, BinaryOperator)
+HANDLE_BINARY_INST(16, Xor   , BinaryOperator)
 
 // Binary comparison operators...
-HANDLE_BINARY_INST(16, SetEQ , SetCondInst)
-HANDLE_BINARY_INST(17, SetNE , SetCondInst)
-HANDLE_BINARY_INST(18, SetLE , SetCondInst)
-HANDLE_BINARY_INST(19, SetGE , SetCondInst)
-HANDLE_BINARY_INST(20, SetLT , SetCondInst)
-HANDLE_BINARY_INST(21, SetGT , SetCondInst)
-  LAST_BINARY_INST(21)
+HANDLE_BINARY_INST(17, SetEQ , SetCondInst)
+HANDLE_BINARY_INST(18, SetNE , SetCondInst)
+HANDLE_BINARY_INST(19, SetLE , SetCondInst)
+HANDLE_BINARY_INST(20, SetGE , SetCondInst)
+HANDLE_BINARY_INST(21, SetLT , SetCondInst)
+HANDLE_BINARY_INST(22, SetGT , SetCondInst)
+  LAST_BINARY_INST(22)
 
 // Memory operators...
- FIRST_MEMORY_INST(22)
-HANDLE_MEMORY_INST(22, Malloc, MallocInst)  // Heap management instructions
-HANDLE_MEMORY_INST(23, Free  , FreeInst  )
-HANDLE_MEMORY_INST(24, Alloca, AllocaInst)  // Stack management
-HANDLE_MEMORY_INST(25, Load  , LoadInst  )  // Memory manipulation instrs
-HANDLE_MEMORY_INST(26, Store , StoreInst )
-HANDLE_MEMORY_INST(27, GetElementPtr, GetElementPtrInst)
-  LAST_MEMORY_INST(27)
+ FIRST_MEMORY_INST(23)
+HANDLE_MEMORY_INST(23, Malloc, MallocInst)  // Heap management instructions
+HANDLE_MEMORY_INST(24, Free  , FreeInst  )
+HANDLE_MEMORY_INST(25, Alloca, AllocaInst)  // Stack management
+HANDLE_MEMORY_INST(26, Load  , LoadInst  )  // Memory manipulation instrs
+HANDLE_MEMORY_INST(27, Store , StoreInst )
+HANDLE_MEMORY_INST(28, GetElementPtr, GetElementPtrInst)
+  LAST_MEMORY_INST(28)
 
 // Other operators...
- FIRST_OTHER_INST(28)
-HANDLE_OTHER_INST(28, PHI, PHINode)  // PHI node instruction
-HANDLE_OTHER_INST(29, Cast   , CastInst   )  // Type cast
-HANDLE_OTHER_INST(30, Call   , CallInst   )  // Call a function
-HANDLE_OTHER_INST(31, Shl, ShiftInst  )  // Shift operations
-HANDLE_OTHER_INST(32, Shr, ShiftInst  )
-HANDLE_OTHER_INST(33, Select , SelectInst )  // select instruction
-HANDLE_OTHER_INST(34, UserOp1, Instruction)  // May be used internally in a 
pass
-HANDLE_OTHER_INST(35, UserOp2, Instruction)
-HANDLE_OTHER_INST(36, VAArg  , VAArgInst  )  // vaarg instruction
-HANDLE_OTHER_INST(37, ExtractElement, ExtractElementInst)// extract from 
vector.
-HANDLE_OTHER_INST(38, InsertElement, InsertElementInst)  // insert into vector
-HANDLE_OTHER_INST(39, ShuffleVector, ShuffleVectorInst)  // shuffle two 
vectors.
-  LAST_OTHER_INST(39)
+ FIRST_OTHER_INST(29)
+HANDLE_OTHER_INST(29, PHI, PHINode)  // PHI node instruction
+HANDLE_OTHER_INST(30, Cast   , CastInst   )  // Type cast
+HANDLE_OTHER_INST(31, Call   , CallInst   )  // Call a function
+HANDLE_OTHER_INST(32, Shl, ShiftInst  )  // Shift operations
+HANDLE_OTHER_INST(33, Shr, ShiftInst  )
+HANDLE_OTHER_INST(34, Select , SelectInst )  // select instruction
+HANDLE_OTHER_INST(35, UserOp1, Instruction)  // May be used internally in a 
pass
+HANDLE_OTHER_INST(36, UserOp2, Instruction)
+HANDLE_OTHER_INST(37, VAArg  , VAArgInst  )  // vaarg instruction
+HANDLE_OTHER_INST(38, ExtractElement, ExtractElementInst)// extract from 

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

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.520.2.6 -> 1.520.2.7
PredicateSimplifier.cpp updated: 1.20.2.1 -> 1.20.2.2
Reassociate.cpp updated: 1.62.2.2 -> 1.62.2.3
---
Log message:

Implement the FDIV instruction for floating point divide.


---
Diffs of the changes:  (+93 -79)

 InstructionCombining.cpp |  170 +--
 PredicateSimplifier.cpp  |1 
 Reassociate.cpp  |1 
 3 files changed, 93 insertions(+), 79 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.6 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.7
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.6   Sat Oct 
21 21:04:31 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Oct 22 03:59:00 2006
@@ -131,8 +131,11 @@
 Instruction *visitAdd(BinaryOperator &I);
 Instruction *visitSub(BinaryOperator &I);
 Instruction *visitMul(BinaryOperator &I);
+Instruction *commonDivTransforms(BinaryOperator &I);
+Instruction *commonIDivTransforms(BinaryOperator &I);
 Instruction *visitUDiv(BinaryOperator &I);
 Instruction *visitSDiv(BinaryOperator &I);
+Instruction *visitFDiv(BinaryOperator &I);
 Instruction *visitRem(BinaryOperator &I);
 Instruction *visitAnd(BinaryOperator &I);
 Instruction *visitOr (BinaryOperator &I);
@@ -2159,15 +2162,19 @@
   return Changed ? &I : 0;
 }
 
-Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
+Instruction* InstCombiner::commonDivTransforms(BinaryOperator &I) {
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
 
   if (isa(Op0))  // undef / X -> 0
 return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
   if (isa(Op1))
 return ReplaceInstUsesWith(I, Op1);  // X / undef -> undef
+  return 0;
+}
+
+Instruction* InstCombiner::commonIDivTransforms(BinaryOperator &I) {
+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
 
-  // If right hand side is a constant intger ..
   if (ConstantInt *RHS = dyn_cast(Op1)) {
 // div X, 1 == X
 if (RHS->equalsInt(1))
@@ -2180,25 +2187,14 @@
 // (X / C1) / C2  -> X / (C1*C2)
 if (Instruction *LHS = dyn_cast(Op0))
   if (LHS->getOpcode() == Instruction::SDiv || 
-  LHS->getOpcode()==Instruction::UDiv)
+  LHS->getOpcode()==Instruction::UDiv ||
+  LHS->getOpcode()==Instruction::FDiv)
 if (ConstantInt *LHSRHS = dyn_cast(LHS->getOperand(1))) {
   return BinaryOperator::create(
 Instruction::BinaryOps(LHS->getOpcode()), LHS->getOperand(0),
   ConstantExpr::getMul(RHS, LHSRHS));
 }
 
-// Check to see if this is an unsigned division with an exact power of 2,
-// if so, convert to a right shift.
-// X udiv C^2 -> X >> C
-if (ConstantInt *C = dyn_cast(RHS)) 
-  if (uint64_t Val = C->getZExtValue())// Don't break X / 0
-if (isPowerOf2_64(Val)) {
-  uint64_t C = Log2_64(Val);
-  return new ShiftInst(Instruction::Shr, Op0,
-   ConstantInt::get(Type::UByteTy, C));
-}
-
-  
 if (!RHS->isNullValue()) { // avoid X udiv 0
   if (SelectInst *SI = dyn_cast(Op0))
 if (Instruction *R = FoldOpIntoSelect(I, SI, this))
@@ -2268,7 +2264,32 @@
 if (LHS->equalsInt(0))
   return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
 
-  // Known to be an unsigned division.
+  return 0;
+}
+
+Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
+
+  Instruction* common = commonDivTransforms(I);
+  if (common)
+return common;
+
+  common = commonIDivTransforms(I);
+  if (common)
+return common;
+
+  // Check to see if this is an unsigned division with an exact power of 2,
+  // if so, convert to a right shift.
+  // X udiv C^2 -> X >> C
+  if (ConstantInt *C = dyn_cast(Op1)) {
+if (uint64_t Val = C->getZExtValue())// Don't break X / 0
+  if (isPowerOf2_64(Val)) {
+uint64_t C = Log2_64(Val);
+return new ShiftInst(Instruction::Shr, Op0,
+ ConstantInt::get(Type::UByteTy, C));
+  }
+  }
+
   if (Instruction *RHSI = dyn_cast(I.getOperand(1))) {
 // Turn A / (C1 << N), where C1 is "1<> (N+C2) [udiv only].
 if (RHSI->getOpcode() == Instruction::Shl &&
@@ -2294,35 +2315,66 @@
 Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
 
-  if (isa(Op0))  // undef / X -> 0
-return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
-  if (isa(Op1))
-return ReplaceInstUsesWith(I, Op1);  // X / undef -> undef
+  Instruction* common = commonDivTransforms(I);
+  if (common)
+return common;
+
+  common = commonIDivTransforms(I);
+  if (common)
+return common;

[llvm-commits] [SignlessTypes] CVS: llvm/lib/VMCore/ConstantFolding.cpp Constants.cpp Instruction.cpp Instructions.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.93.2.5 -> 1.93.2.6
Constants.cpp updated: 1.163.2.7 -> 1.163.2.8
Instruction.cpp updated: 1.53.2.3 -> 1.53.2.4
Instructions.cpp updated: 1.42.2.4 -> 1.42.2.5
---
Log message:

Implement the FDIV instruction for floating point divide.


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

 ConstantFolding.cpp |   25 +
 Constants.cpp   |6 +-
 Instruction.cpp |4 +++-
 Instructions.cpp|2 +-
 4 files changed, 26 insertions(+), 11 deletions(-)


Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.5 
llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.6
--- llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.5Fri Oct 20 03:01:26 2006
+++ llvm/lib/VMCore/ConstantFolding.cpp Sun Oct 22 03:59:01 2006
@@ -42,6 +42,7 @@
 virtual Constant *mul(const Constant *V1, const Constant *V2) const = 0;
 virtual Constant *udiv(const Constant *V1, const Constant *V2) const = 0;
 virtual Constant *sdiv(const Constant *V1, const Constant *V2) const = 0;
+virtual Constant *fdiv(const Constant *V1, const Constant *V2) const = 0;
 virtual Constant *rem(const Constant *V1, const Constant *V2) const = 0;
 virtual Constant *op_and(const Constant *V1, const Constant *V2) const = 0;
 virtual Constant *op_or (const Constant *V1, const Constant *V2) const = 0;
@@ -113,6 +114,9 @@
   virtual Constant *sdiv(const Constant *V1, const Constant *V2) const {
 return SubClassName::SDiv((const ArgType *)V1, (const ArgType *)V2);
   }
+  virtual Constant *fdiv(const Constant *V1, const Constant *V2) const {
+return SubClassName::FDiv((const ArgType *)V1, (const ArgType *)V2);
+  }
   virtual Constant *rem(const Constant *V1, const Constant *V2) const {
 return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2);
   }
@@ -187,6 +191,7 @@
   static Constant *Mul (const ArgType *V1, const ArgType *V2) { return 0; }
   static Constant *SDiv(const ArgType *V1, const ArgType *V2) { return 0; }
   static Constant *UDiv(const ArgType *V1, const ArgType *V2) { return 0; }
+  static Constant *FDiv(const ArgType *V1, const ArgType *V2) { return 0; }
   static Constant *Rem (const ArgType *V1, const ArgType *V2) { return 0; }
   static Constant *And (const ArgType *V1, const ArgType *V2) { return 0; }
   static Constant *Or  (const ArgType *V1, const ArgType *V2) { return 0; }
@@ -384,6 +389,9 @@
   static Constant *SDiv(const ConstantPacked *V1, const ConstantPacked *V2) {
 return EvalVectorOp(V1, V2, ConstantExpr::getSDiv);
   }
+  static Constant *FDiv(const ConstantPacked *V1, const ConstantPacked *V2) {
+return EvalVectorOp(V1, V2, ConstantExpr::getFDiv);
+  }
   static Constant *Rem(const ConstantPacked *V1, const ConstantPacked *V2) {
 return EvalVectorOp(V1, V2, ConstantExpr::getRem);
   }
@@ -635,14 +643,7 @@
(BuiltinType)V2->getValue());
 return ConstantFP::get(*Ty, Result);
   }
-  static Constant *UDiv(const ConstantFP *V1, const ConstantFP *V2) {
-BuiltinType inf = std::numeric_limits::infinity();
-if (V2->isExactlyValue(0.0)) return ConstantFP::get(*Ty, inf);
-if (V2->isExactlyValue(-0.0)) return ConstantFP::get(*Ty, -inf);
-BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue();
-return ConstantFP::get(*Ty, R);
-  }
-  static Constant *SDiv(const ConstantFP *V1, const ConstantFP *V2) {
+  static Constant *FDiv(const ConstantFP *V1, const ConstantFP *V2) {
 BuiltinType inf = std::numeric_limits::infinity();
 if (V2->isExactlyValue(0.0)) return ConstantFP::get(*Ty, inf);
 if (V2->isExactlyValue(-0.0)) return ConstantFP::get(*Ty, -inf);
@@ -1253,6 +1254,7 @@
   case Instruction::Mul: C = ConstRules::get(V1, V2).mul(V1, V2); break;
   case Instruction::UDiv:C = ConstRules::get(V1, V2).udiv(V1, V2); break;
   case Instruction::SDiv:C = ConstRules::get(V1, V2).sdiv(V1, V2); break;
+  case Instruction::FDiv:C = ConstRules::get(V1, V2).fdiv(V1, V2); break;
   case Instruction::Rem: C = ConstRules::get(V1, V2).rem(V1, V2); break;
   case Instruction::And: C = ConstRules::get(V1, V2).op_and(V1, V2); break;
   case Instruction::Or:  C = ConstRules::get(V1, V2).op_or (V1, V2); break;
@@ -1337,6 +1339,7 @@
   return Constant::getNullValue(V1->getType());
 case Instruction::UDiv:
 case Instruction::SDiv:
+case Instruction::FDiv:
 case Instruction::Rem:
   if (!isa(V2)) // undef/X -> 0
 return Constant::getNullValue(V1->getType());
@@ -1393,6 +1396,11 @@
   if (CI->getZExtValue() == 1)
 return const_cast(V1); // X / 1 == X
 break;
+  case Instruction::FDiv:
+if (const ConstantFP* CFP = dyn_cast(V2)) // X / 1.0 
== X
+  if (CFP->getValue() == 1.0)
+return const_cast(V1);
+break;
   case Instruction::Rem:
 if (co

[llvm-commits] [SignlessTypes] CVS: llvm/lib/Target/CBackend/Writer.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.272.2.3 -> 1.272.2.4
---
Log message:

Implement the FDIV instruction for floating point divide.


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

 Writer.cpp |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.272.2.3 
llvm/lib/Target/CBackend/Writer.cpp:1.272.2.4
--- llvm/lib/Target/CBackend/Writer.cpp:1.272.2.3   Fri Oct 20 03:19:49 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Sun Oct 22 03:59:00 2006
@@ -588,6 +588,7 @@
 case Instruction::Mul:
 case Instruction::SDiv:
 case Instruction::UDiv:
+case Instruction::FDiv:
 case Instruction::Rem:
 case Instruction::And:
 case Instruction::Or:
@@ -607,7 +608,8 @@
   case Instruction::Sub: Out << " - "; break;
   case Instruction::Mul: Out << " * "; break;
   case Instruction::UDiv: 
-  case Instruction::SDiv: Out << " / "; break;
+  case Instruction::SDiv: 
+  case Instruction::FDiv: Out << " / "; break;
   case Instruction::Rem: Out << " % "; break;
   case Instruction::And: Out << " & "; break;
   case Instruction::Or:  Out << " | "; break;
@@ -1651,7 +1653,8 @@
 case Instruction::Sub: Out << " - "; break;
 case Instruction::Mul: Out << '*'; break;
 case Instruction::UDiv:
-case Instruction::SDiv: Out << '/'; break;
+case Instruction::SDiv: 
+case Instruction::FDiv: Out << '/'; break;
 case Instruction::Rem: Out << '%'; break;
 case Instruction::And: Out << " & "; break;
 case Instruction::Or: Out << " | "; break;



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


[llvm-commits] [SignlessTypes] CVS: llvm/lib/Bytecode/Reader/Reader.cpp

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.198.2.4 -> 1.198.2.5
---
Log message:

Implement the FDIV instruction for floating point divide.


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

 Reader.cpp |   18 --
 1 files changed, 12 insertions(+), 6 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.4 
llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.5
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.198.2.4   Sat Oct 21 03:59:42 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Oct 22 03:59:00 2006
@@ -633,8 +633,9 @@
   // either udiv or sdiv based on that type. This expression selects the
   // cases where the type is floating point or signed in which case we
   // generated an sdiv instruction.
-  if (iType == 10 || iType == 11 || // select floating point
-  (iType >= 2 && iType <= 9 && iType % 2 != 0))
+  if (iType == 10 || iType == 11 )
+Opcode = Instruction::FDiv;
+  else if (iType >= 2 && iType <= 9 && iType % 2 != 0)
 Opcode = Instruction::SDiv;
   else
 Opcode = Instruction::UDiv;
@@ -643,8 +644,9 @@
 case 11: // Rem
   // As with "Div", make the signed/unsigned Rem instruction choice based
   // on the type of the instruction.
-  if (iType == 10 || iType == 11 || // select floating point
-  (iType >= 2 && iType <= 9 && iType % 2 != 0))
+  if (iType == 10 || iType == 11)
+Opcode = Instruction::Rem;
+  else if (iType >= 2 && iType <= 9 && iType % 2 != 0)
 Opcode = Instruction::Rem;
   else
 Opcode = Instruction::Rem;
@@ -1620,7 +1622,9 @@
   // either udiv or sdiv based on that type. This expression selects the
   // cases where the type is floating point or signed in which case we
   // generated an sdiv instruction.
-  if (ArgVec[0]->getType()->isSigned())
+  if (ArgVec[0]->getType()->isFloatingPoint())
+Opcode = Instruction::FDiv;
+  else if (ArgVec[0]->getType()->isSigned())
 Opcode = Instruction::SDiv;
   else
 Opcode = Instruction::UDiv;
@@ -1629,7 +1633,9 @@
 case 11: // Rem
   // As with "Div", make the signed/unsigned Rem instruction choice based
   // on the type of the instruction.
-  if (ArgVec[0]->getType()->isSigned())
+  if (ArgVec[0]->getType()->isFloatingPoint())
+Opcode = Instruction::Rem;
+  else if (ArgVec[0]->getType()->isSigned())
 Opcode = Instruction::Rem;
   else
 Opcode = Instruction::Rem;



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


Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l

2006-10-22 Thread Reid Spencer
On Sat, 2006-10-21 at 23:09 -0700, Chris Lattner wrote:
> >> @@ -1873,6 +1874,11 @@
> >>  free($3);
> >>  CHECK_FOR_ERROR
> >>};
> >> +  | DATA '=' STRINGCONSTANT {
> >> +CurModule.CurrentModule->setDataLayout($3);
> >> +free($3);
> >> +CHECK_FOR_ERROR
> >
> > I don't think you need a CHECK_FOR_ERROR here. Neither of the two
> > preceding calls will call GENERATE_ERROR.
> 
> Owen/Reid: can one of you take care of this?

Done.

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


[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

2006-10-22 Thread Reid Spencer


Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.268 -> 1.269
---
Log message:

Remove unneeded CHECK_FOR_ERROR invocations.


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

 llvmAsmParser.y |2 --
 1 files changed, 2 deletions(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.268 
llvm/lib/AsmParser/llvmAsmParser.y:1.269
--- llvm/lib/AsmParser/llvmAsmParser.y:1.268Sun Oct 22 01:07:41 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y  Sun Oct 22 02:03:09 2006
@@ -1872,12 +1872,10 @@
   | TRIPLE '=' STRINGCONSTANT {
 CurModule.CurrentModule->setTargetTriple($3);
 free($3);
-CHECK_FOR_ERROR
   };
   | DATALAYOUT '=' STRINGCONSTANT {
 CurModule.CurrentModule->setDataLayout($3);
 free($3);
-CHECK_FOR_ERROR
   };
 
 LibrariesDefinition : '[' LibList ']';



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