Try to fold each element of a vector. This is needed to maintain structural

equivalence.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55694 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2008-09-03 06:48:55 +00:00
parent 8b19e56051
commit 8373d38afd

View File

@ -238,12 +238,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
std::vector<Constant*> res;
const VectorType *DestVecTy = cast<VectorType>(DestTy);
const Type *DstEltTy = DestVecTy->getElementType();
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) {
Constant *C = ConstantFoldCastInstruction(opc, CV->getOperand(i),
DstEltTy);
if (!C) return 0; // Can't fold operand.
res.push_back(C);
}
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
res.push_back(ConstantExpr::getCast(opc, CV->getOperand(i), DstEltTy));
return ConstantVector::get(DestVecTy, res);
}
return 0; // Can't fold.
@ -271,12 +267,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
std::vector<Constant*> res;
const VectorType *DestVecTy = cast<VectorType>(DestTy);
const Type *DstEltTy = DestVecTy->getElementType();
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) {
Constant *C = ConstantFoldCastInstruction(opc, CV->getOperand(i),
DstEltTy);
if (!C) return 0; // Can't fold operand.
res.push_back(C);
}
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
res.push_back(ConstantExpr::getCast(opc, CV->getOperand(i), DstEltTy));
return ConstantVector::get(DestVecTy, res);
}
return 0;