diff options
author | Dan Gohman <gohman@apple.com> | 2008-06-03 00:15:20 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-06-03 00:15:20 +0000 |
commit | b662af24c72866da76a1a67b690253883f304433 (patch) | |
tree | a24c1073c60b8272c89e9b770fc8293782c0b426 /lib/VMCore/Constants.cpp | |
parent | 52f93c058ee2fe36e0416ceecd3b8804d2bd1ef1 (diff) | |
download | external_llvm-b662af24c72866da76a1a67b690253883f304433.zip external_llvm-b662af24c72866da76a1a67b690253883f304433.tar.gz external_llvm-b662af24c72866da76a1a67b690253883f304433.tar.bz2 |
Constant folding for insertvalue and extractvalue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 9c10e75..530f7ba 100644 --- a/lib/VMCore/Constants.cpp +++ b/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); |