aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-03-31 18:25:14 +0000
committerChris Lattner <sabre@nondot.org>2006-03-31 18:25:14 +0000
commit1f13c88939e2d243c9802f7da83ae8daccb285eb (patch)
treeb338a46d985604fe46c51c4f3ddcc0e0dce69a39
parentc741ea424a290373b24b06b77f161d06f08f7fa7 (diff)
downloadexternal_llvm-1f13c88939e2d243c9802f7da83ae8daccb285eb.zip
external_llvm-1f13c88939e2d243c9802f7da83ae8daccb285eb.tar.gz
external_llvm-1f13c88939e2d243c9802f7da83ae8daccb285eb.tar.bz2
extractelement(undef,x) -> undef
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27300 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index cd73456..f69d869 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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