diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-03-31 18:25:14 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-03-31 18:25:14 +0000 |
| commit | 92346c315e001080f359f8d2ea10610941e98c6d (patch) | |
| tree | 6376f02f7b90e133538802b0528a0dee4bc02837 /llvm/lib/Transforms | |
| parent | d9e4daabd241d245657ae4dc9bec01bdb91a32c3 (diff) | |
| download | bcm5719-llvm-92346c315e001080f359f8d2ea10610941e98c6d.tar.gz bcm5719-llvm-92346c315e001080f359f8d2ea10610941e98c6d.zip | |
extractelement(undef,x) -> undef
llvm-svn: 27300
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index cd734568ba5..f69d869c12e 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -6655,12 +6655,14 @@ static bool CheapToScalarize(Value *V, bool isConstant) { } Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { - if (ConstantAggregateZero *C = - dyn_cast<ConstantAggregateZero>(EI.getOperand(0))) { - // If packed val is constant 0, replace extract with scalar 0 - const Type *Ty = cast<PackedType>(C->getType())->getElementType(); - return ReplaceInstUsesWith(EI, Constant::getNullValue(Ty)); - } + // If packed val is undef, replace extract with scalar undef. + if (isa<UndefValue>(EI.getOperand(0))) + return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType())); + + // If packed val is constant 0, replace extract with scalar 0. + if (isa<ConstantAggregateZero>(EI.getOperand(0))) + return ReplaceInstUsesWith(EI, Constant::getNullValue(EI.getType())); + if (ConstantPacked *C = dyn_cast<ConstantPacked>(EI.getOperand(0))) { // If packed val is constant with uniform operands, replace EI // with that operand |

