Teach BinaryOperator::createNot to work with packed integer types
authorChris Lattner <sabre@nondot.org>
Sat, 25 Mar 2006 21:54:21 +0000 (21:54 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 25 Mar 2006 21:54:21 +0000 (21:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27124 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Instructions.cpp

index 0bd55c915123f93e82b62868287b34f251f82a53..f28a413a172ace1d94d89dd5ce12d17a7ab71aa1 100644 (file)
@@ -923,8 +923,15 @@ BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
 
 BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name,
                                           Instruction *InsertBefore) {
-  return new BinaryOperator(Instruction::Xor, Op,
-                            ConstantIntegral::getAllOnesValue(Op->getType()),
+  Constant *C;
+  if (const PackedType *PTy = dyn_cast<PackedType>(Op->getType())) {
+    C = ConstantIntegral::getAllOnesValue(PTy->getElementType());
+    C = ConstantPacked::get(std::vector<Constant*>(PTy->getNumElements(), C));
+  } else {
+    C = ConstantIntegral::getAllOnesValue(Op->getType());
+  }
+  
+  return new BinaryOperator(Instruction::Xor, Op, C,
                             Op->getType(), Name, InsertBefore);
 }