aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-12-21 18:22:19 +0000
committerChris Lattner <sabre@nondot.org>2005-12-21 18:22:19 +0000
commitb9d4100f327647debd0936fe403cdef00ab56859 (patch)
treeb92abd1e47b55124dfdf3470b8efd375911d89e0 /lib
parent83397363348662e9352455ea1e6e88e7026300a4 (diff)
downloadexternal_llvm-b9d4100f327647debd0936fe403cdef00ab56859.zip
external_llvm-b9d4100f327647debd0936fe403cdef00ab56859.tar.gz
external_llvm-b9d4100f327647debd0936fe403cdef00ab56859.tar.bz2
Get logical operations to like packed types, allow BinOp::getNot to create
the right vector of -1's as its operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Instructions.cpp22
-rw-r--r--lib/VMCore/Verifier.cpp4
2 files changed, 19 insertions, 7 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 48f3ed0..1b8d038 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -811,16 +811,17 @@ void BinaryOperator::init(BinaryOps iType)
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,
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);
}
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 39800b1..8b371f9 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -498,7 +498,9 @@ void Verifier::visitBinaryOperator(BinaryOperator &B) {
// 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!",