summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-09-03 06:48:55 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-09-03 06:48:55 +0000
commit8373d38afddec4ade17f72088cb5eeb229e87238 (patch)
tree771462299e67d8321fcc985cbaf1abb469a801a5 /lib/VMCore
parent8b19e56051c45c3e48523238a5a0f33bbac0115d (diff)
downloadllvm-8373d38afddec4ade17f72088cb5eeb229e87238.tar.gz
llvm-8373d38afddec4ade17f72088cb5eeb229e87238.tar.bz2
llvm-8373d38afddec4ade17f72088cb5eeb229e87238.tar.xz
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
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantFold.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 25c756ab6e..93cfccf1f5 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -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;