mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
constant fold extractelement with undef operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27301 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1f13c88939
commit
6fa4cdf92e
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user