extractelement(undef,x) -> undef

llvm-svn: 27300
This commit is contained in:
Chris Lattner 2006-03-31 18:25:14 +00:00
parent d9e4daabd2
commit 92346c315e
1 changed files with 8 additions and 6 deletions

View File

@ -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