Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.28 -> 1.29
Verifier.cpp updated: 1.135 -> 1.136
---
Log message:

Get logical operations to like packed types, allow BinOp::getNot to create
the right vector of -1's as its operand.


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

 Instructions.cpp |   22 ++++++++++++++++------
 Verifier.cpp     |    4 +++-
 2 files changed, 19 insertions(+), 7 deletions(-)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.28 
llvm/lib/VMCore/Instructions.cpp:1.29
--- llvm/lib/VMCore/Instructions.cpp:1.28       Sat Nov  5 15:57:54 2005
+++ llvm/lib/VMCore/Instructions.cpp    Wed Dec 21 12:22:19 2005
@@ -811,16 +811,17 @@
   case Rem:
     assert(getType() == LHS->getType() &&
            "Arithmetic operation should return same type as operands!");
-    assert((getType()->isInteger() ||
-            getType()->isFloatingPoint() ||
-            isa<PackedType>(getType()) ) &&
+    assert((getType()->isInteger() || getType()->isFloatingPoint() ||
+            isa<PackedType>(getType())) &&
           "Tried to create an arithmetic operation on a non-arithmetic type!");
     break;
   case And: case Or:
   case Xor:
     assert(getType() == LHS->getType() &&
            "Logical operation should return same type as operands!");
-    assert(getType()->isIntegral() &&
+    assert((getType()->isIntegral() ||
+            (isa<PackedType>(getType()) && 
+             cast<PackedType>(getType())->getElementType()->isIntegral())) &&
            "Tried to create a logical operation on a non-integral type!");
     break;
   case SetLT: case SetGT: case SetLE:
@@ -889,8 +890,17 @@
 
 BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name,
                                           BasicBlock *InsertAtEnd) {
-  return new BinaryOperator(Instruction::Xor, Op,
-                            ConstantIntegral::getAllOnesValue(Op->getType()),
+  Constant *AllOnes;
+  if (const PackedType *PTy = dyn_cast<PackedType>(Op->getType())) {
+    // Create a vector of all ones values.
+    Constant *Elt = ConstantIntegral::getAllOnesValue(PTy->getElementType());
+    AllOnes = 
+      ConstantPacked::get(std::vector<Constant*>(PTy->getNumElements(), Elt));
+  } else {
+    AllOnes = ConstantIntegral::getAllOnesValue(Op->getType());
+  }
+  
+  return new BinaryOperator(Instruction::Xor, Op, AllOnes,
                             Op->getType(), Name, InsertAtEnd);
 }
 


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.135 llvm/lib/VMCore/Verifier.cpp:1.136
--- llvm/lib/VMCore/Verifier.cpp:1.135  Fri Nov 11 10:46:18 2005
+++ llvm/lib/VMCore/Verifier.cpp        Wed Dec 21 12:22:19 2005
@@ -498,7 +498,9 @@
   // Check that logical operators are only used with integral operands.
   if (B.getOpcode() == Instruction::And || B.getOpcode() == Instruction::Or ||
       B.getOpcode() == Instruction::Xor) {
-    Assert1(B.getType()->isIntegral(),
+    Assert1(B.getType()->isIntegral() ||
+            (isa<PackedType>(B.getType()) && 
+             cast<PackedType>(B.getType())->getElementType()->isIntegral()),
             "Logical operators only work with integral types!", &B);
     Assert1(B.getType() == B.getOperand(0)->getType(),
             "Logical operators must have same type for operands and result!",



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

Reply via email to