diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-12-21 18:22:19 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-12-21 18:22:19 +0000 |
| commit | dca56cbd9a257e89c4981a54aa8c54287002850b (patch) | |
| tree | abb5b3c7ff761beb707351b990c3039f8cda077c /llvm/lib/VMCore/Instructions.cpp | |
| parent | ac12f684240b5f868cbbeb0e82ae9c9a9b052ef1 (diff) | |
| download | bcm5719-llvm-dca56cbd9a257e89c4981a54aa8c54287002850b.tar.gz bcm5719-llvm-dca56cbd9a257e89c4981a54aa8c54287002850b.zip | |
Get logical operations to like packed types, allow BinOp::getNot to create
the right vector of -1's as its operand.
llvm-svn: 24906
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
| -rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 48f3ed0e5f3..1b8d0387cf9 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/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); } |

