summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-04-27 21:14:21 +0000
committerChris Lattner <sabre@nondot.org>2006-04-27 21:14:21 +0000
commitb6cb64b7e69cef2f02683df44e053a1ce0a2083c (patch)
tree2d8168b97e4d16a7775d93274f951073dfcfa203 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent51fecaa8b3ac295a1712d108e87a198b5e3f41e2 (diff)
downloadbcm5719-llvm-b6cb64b7e69cef2f02683df44e053a1ce0a2083c.tar.gz
bcm5719-llvm-b6cb64b7e69cef2f02683df44e053a1ce0a2083c.zip
Add support for inserting undef into a vector. This implements
Transforms/InstCombine/vec_insert_to_shuffle.ll llvm-svn: 27997
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 1c4bceaef40..590e0d9d97e 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -6959,12 +6959,23 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS,
Value *ScalarOp = IEI->getOperand(1);
Value *IdxOp = IEI->getOperand(2);
- if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)) {
- if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
+ if (!isa<ConstantInt>(IdxOp))
+ return false;
+ unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue();
+
+ if (isa<UndefValue>(ScalarOp)) { // inserting undef into vector.
+ // Okay, we can handle this if the vector we are insertinting into is
+ // transitively ok.
+ if (CollectSingleShuffleElements(VecOp, LHS, RHS, Mask)) {
+ // If so, update the mask to reflect the inserted undef.
+ Mask[InsertedIdx] = UndefValue::get(Type::UIntTy);
+ return true;
+ }
+ } else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
+ if (isa<ConstantInt>(EI->getOperand(1)) &&
EI->getOperand(0)->getType() == V->getType()) {
unsigned ExtractedIdx =
cast<ConstantInt>(EI->getOperand(1))->getRawValue();
- unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue();
// This must be extracting from either LHS or RHS.
if (EI->getOperand(0) == LHS || EI->getOperand(0) == RHS) {
OpenPOWER on IntegriCloud