From e089160d1065d83986fd97fae7f0af08c03e7d47 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 21 Jul 2008 23:30:30 +0000 Subject: InsertValue and ExtractValue constant expressions are always folded. Remove code that handled the case where they aren't folded, and remove bitcode reader/writer support for them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53887 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Constants.cpp | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) (limited to 'lib/VMCore') diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 48b0a8f31a..e22449bab6 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -857,19 +857,6 @@ ConstantExpr::getWithOperandReplaced(unsigned OpNo, Constant *Op) const { Op1 = (OpNo == 1) ? Op : getOperand(1); Op2 = (OpNo == 2) ? Op : getOperand(2); return ConstantExpr::getShuffleVector(Op0, Op1, Op2); - case Instruction::InsertValue: { - const SmallVector &Indices = getIndices(); - Op0 = (OpNo == 0) ? Op : getOperand(0); - Op1 = (OpNo == 1) ? Op : getOperand(1); - return ConstantExpr::getInsertValue(Op0, Op1, - &Indices[0], Indices.size()); - } - case Instruction::ExtractValue: { - assert(OpNo == 0 && "ExtractaValue has only one operand!"); - const SmallVector &Indices = getIndices(); - return - ConstantExpr::getExtractValue(Op, &Indices[0], Indices.size()); - } case Instruction::GetElementPtr: { SmallVector Ops; Ops.resize(getNumOperands()-1); @@ -925,16 +912,6 @@ getWithOperands(const std::vector &Ops) const { return ConstantExpr::getExtractElement(Ops[0], Ops[1]); case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); - case Instruction::InsertValue: { - const SmallVector &Indices = getIndices(); - return ConstantExpr::getInsertValue(Ops[0], Ops[1], - &Indices[0], Indices.size()); - } - case Instruction::ExtractValue: { - const SmallVector &Indices = getIndices(); - return ConstantExpr::getExtractValue(Ops[0], - &Indices[0], Indices.size()); - } case Instruction::GetElementPtr: return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1); case Instruction::ICmp: @@ -2365,15 +2342,9 @@ Constant *ConstantExpr::getInsertValueTy(const Type *ReqTy, Constant *Agg, "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 ArgVec; - ArgVec.push_back(Agg); - ArgVec.push_back(Val); - SmallVector Indices(Idxs, Idxs + NumIdx); - const ExprMapKeyType Key(Instruction::InsertValue, ArgVec, 0, Indices); - return ExprConstants->getOrCreate(ReqTy, Key); + Constant *FC = ConstantFoldInsertValueInstruction(Agg, Val, Idxs, NumIdx); + assert(FC && "InsertValue constant expr couldn't be folded!"); + return FC; } Constant *ConstantExpr::getInsertValue(Constant *Agg, Constant *Val, @@ -2395,14 +2366,9 @@ 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 ArgVec; - ArgVec.push_back(Agg); - SmallVector Indices(Idxs, Idxs + NumIdx); - const ExprMapKeyType Key(Instruction::ExtractValue, ArgVec, 0, Indices); - return ExprConstants->getOrCreate(ReqTy, Key); + Constant *FC = ConstantFoldExtractValueInstruction(Agg, Idxs, NumIdx); + assert(FC && "ExtractValue constant expr couldn't be folded!"); + return FC; } Constant *ConstantExpr::getExtractValue(Constant *Agg, -- cgit v1.2.3