summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-06-03 00:15:20 +0000
committerDan Gohman <gohman@apple.com>2008-06-03 00:15:20 +0000
commit3db11c2bd972cf4d896568dc49b460c3914f5aa2 (patch)
tree3e9cf586226a6959f97cc19d85ddea74bb648cd0 /llvm/lib/VMCore/Constants.cpp
parentebf4cb48416afa3bcd06ab9baab96e9b12ad6f43 (diff)
downloadbcm5719-llvm-3db11c2bd972cf4d896568dc49b460c3914f5aa2.tar.gz
bcm5719-llvm-3db11c2bd972cf4d896568dc49b460c3914f5aa2.zip
Constant folding for insertvalue and extractvalue.
llvm-svn: 51889
Diffstat (limited to 'llvm/lib/VMCore/Constants.cpp')
-rw-r--r--llvm/lib/VMCore/Constants.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 9c10e75c8df..530f7ba61aa 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -2305,9 +2305,10 @@ Constant *ConstantExpr::getInsertValueTy(const Type *ReqTy, Constant *Agg,
"insertvalue indices invalid!");
assert(Agg->getType() == ReqTy &&
"insertvalue type invalid!");
-
assert(Agg->getType()->isFirstClassType() &&
"Non-first-class type for constant InsertValue expression");
+ if (Constant *FC = ConstantFoldInsertValueInstruction(Agg, Val, Idxs, NumIdx))
+ return FC; // Fold a few common cases...
// Look up the constant in the table first to ensure uniqueness
std::vector<Constant*> ArgVec;
ArgVec.push_back(Agg);
@@ -2336,6 +2337,8 @@ Constant *ConstantExpr::getExtractValueTy(const Type *ReqTy, Constant *Agg,
"extractvalue indices invalid!");
assert(Agg->getType()->isFirstClassType() &&
"Non-first-class type for constant extractvalue expression");
+ if (Constant *FC = ConstantFoldExtractValueInstruction(Agg, Idxs, NumIdx))
+ return FC; // Fold a few common cases...
// Look up the constant in the table first to ensure uniqueness
std::vector<Constant*> ArgVec;
ArgVec.push_back(Agg);
OpenPOWER on IntegriCloud