diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-03-31 18:31:40 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-03-31 18:31:40 +0000 |
| commit | e52f29b243d8b0b9cbd82c6d99c890703f0732c6 (patch) | |
| tree | e982b45474f29ea912bf948062ce22227a790227 /llvm/lib/VMCore/ConstantFolding.cpp | |
| parent | 92346c315e001080f359f8d2ea10610941e98c6d (diff) | |
| download | bcm5719-llvm-e52f29b243d8b0b9cbd82c6d99c890703f0732c6.tar.gz bcm5719-llvm-e52f29b243d8b0b9cbd82c6d99c890703f0732c6.zip | |
constant fold extractelement with undef operands.
llvm-svn: 27301
Diffstat (limited to 'llvm/lib/VMCore/ConstantFolding.cpp')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFolding.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp index a6fbf42fa24..ee5ee0ee42c 100644 --- a/llvm/lib/VMCore/ConstantFolding.cpp +++ b/llvm/lib/VMCore/ConstantFolding.cpp @@ -726,11 +726,17 @@ Constant *llvm::ConstantFoldSelectInstruction(const Constant *Cond, Constant *llvm::ConstantFoldExtractElementInstruction(const Constant *Val, const Constant *Idx) { + if (isa<UndefValue>(Val)) // ee(undef, x) -> undef + return UndefValue::get(cast<PackedType>(Val->getType())->getElementType()); + if (const ConstantPacked *CVal = dyn_cast<ConstantPacked>(Val)) { if (const ConstantUInt *CIdx = dyn_cast<ConstantUInt>(Idx)) { return const_cast<Constant*>(CVal->getOperand(CIdx->getValue())); + } else if (isa<UndefValue>(Idx)) { + // ee({w,x,y,z}, undef) -> w (an arbitrary value). + return const_cast<Constant*>(CVal->getOperand(0)); } - } + } return 0; } |

