diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 2 | ||||
-rw-r--r-- | lib/AsmParser/LLLexer.cpp | 1 | ||||
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 39 | ||||
-rw-r--r-- | lib/AsmParser/LLToken.h | 2 | ||||
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 38 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 22 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 27 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.h | 4 | ||||
-rw-r--r-- | lib/Target/ARM/ARMISelLowering.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 40 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 90 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 127 | ||||
-rw-r--r-- | lib/VMCore/Instruction.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 31 | ||||
-rw-r--r-- | lib/VMCore/LLVMContext.cpp | 10 |
15 files changed, 75 insertions, 362 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 7ebfec3..ffdc52c 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -365,8 +365,6 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, return 0; case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: assert(0 &&"This function is invalid for compares: no predicate specified"); case Instruction::PtrToInt: // If the input is a inttoptr, eliminate the pair. This requires knowing diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index cab9417..10e5a60 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -591,7 +591,6 @@ lltok::Kind LLLexer::LexIdentifier() { INSTKEYWORD(shl, Shl); INSTKEYWORD(lshr, LShr); INSTKEYWORD(ashr, AShr); INSTKEYWORD(and, And); INSTKEYWORD(or, Or); INSTKEYWORD(xor, Xor); INSTKEYWORD(icmp, ICmp); INSTKEYWORD(fcmp, FCmp); - INSTKEYWORD(vicmp, VICmp); INSTKEYWORD(vfcmp, VFCmp); INSTKEYWORD(phi, PHI); INSTKEYWORD(call, Call); diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 49509d5..8c30ab5 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1847,9 +1847,7 @@ bool LLParser::ParseValID(ValID &ID) { return false; } case lltok::kw_icmp: - case lltok::kw_fcmp: - case lltok::kw_vicmp: - case lltok::kw_vfcmp: { + case lltok::kw_fcmp: { unsigned PredVal, Opc = Lex.getUIntVal(); Constant *Val0, *Val1; Lex.Lex(); @@ -1870,23 +1868,12 @@ bool LLParser::ParseValID(ValID &ID) { if (!Val0->getType()->isFPOrFPVector()) return Error(ID.Loc, "fcmp requires floating point operands"); ID.ConstantVal = Context.getConstantExprFCmp(Pred, Val0, Val1); - } else if (Opc == Instruction::ICmp) { + } else { + assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!"); if (!Val0->getType()->isIntOrIntVector() && !isa<PointerType>(Val0->getType())) return Error(ID.Loc, "icmp requires pointer or integer operands"); ID.ConstantVal = Context.getConstantExprICmp(Pred, Val0, Val1); - } else if (Opc == Instruction::VFCmp) { - // FIXME: REMOVE VFCMP Support - if (!Val0->getType()->isFPOrFPVector() || - !isa<VectorType>(Val0->getType())) - return Error(ID.Loc, "vfcmp requires vector floating point operands"); - ID.ConstantVal = Context.getConstantExprVFCmp(Pred, Val0, Val1); - } else if (Opc == Instruction::VICmp) { - // FIXME: REMOVE VICMP Support - if (!Val0->getType()->isIntOrIntVector() || - !isa<VectorType>(Val0->getType())) - return Error(ID.Loc, "vicmp requires vector floating point operands"); - ID.ConstantVal = Context.getConstantExprVICmp(Pred, Val0, Val1); } ID.Kind = ValID::t_Constant; return false; @@ -2485,9 +2472,7 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB, case lltok::kw_or: case lltok::kw_xor: return ParseLogical(Inst, PFS, KeywordVal); case lltok::kw_icmp: - case lltok::kw_fcmp: - case lltok::kw_vicmp: - case lltok::kw_vfcmp: return ParseCompare(Inst, PFS, KeywordVal); + case lltok::kw_fcmp: return ParseCompare(Inst, PFS, KeywordVal); // Casts. case lltok::kw_trunc: case lltok::kw_zext: @@ -2532,8 +2517,7 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB, /// ParseCmpPredicate - Parse an integer or fp predicate, based on Kind. bool LLParser::ParseCmpPredicate(unsigned &P, unsigned Opc) { - // FIXME: REMOVE vicmp/vfcmp! - if (Opc == Instruction::FCmp || Opc == Instruction::VFCmp) { + if (Opc == Instruction::FCmp) { switch (Lex.getKind()) { default: TokError("expected fcmp predicate (e.g. 'oeq')"); case lltok::kw_oeq: P = CmpInst::FCMP_OEQ; break; @@ -2862,8 +2846,6 @@ bool LLParser::ParseLogical(Instruction *&Inst, PerFunctionState &PFS, /// ParseCompare /// ::= 'icmp' IPredicates TypeAndValue ',' Value /// ::= 'fcmp' FPredicates TypeAndValue ',' Value -/// ::= 'vicmp' IPredicates TypeAndValue ',' Value -/// ::= 'vfcmp' FPredicates TypeAndValue ',' Value bool LLParser::ParseCompare(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc) { // Parse the integer/fp comparison predicate. @@ -2880,19 +2862,12 @@ bool LLParser::ParseCompare(Instruction *&Inst, PerFunctionState &PFS, if (!LHS->getType()->isFPOrFPVector()) return Error(Loc, "fcmp requires floating point operands"); Inst = new FCmpInst(CmpInst::Predicate(Pred), LHS, RHS); - } else if (Opc == Instruction::ICmp) { + } else { + assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!"); if (!LHS->getType()->isIntOrIntVector() && !isa<PointerType>(LHS->getType())) return Error(Loc, "icmp requires integer operands"); Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS); - } else if (Opc == Instruction::VFCmp) { - if (!LHS->getType()->isFPOrFPVector() || !isa<VectorType>(LHS->getType())) - return Error(Loc, "vfcmp requires vector floating point operands"); - Inst = new VFCmpInst(CmpInst::Predicate(Pred), LHS, RHS); - } else if (Opc == Instruction::VICmp) { - if (!LHS->getType()->isIntOrIntVector() || !isa<VectorType>(LHS->getType())) - return Error(Loc, "vicmp requires vector floating point operands"); - Inst = new VICmpInst(CmpInst::Predicate(Pred), LHS, RHS); } return false; } diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h index cff89f8..b5194ad 100644 --- a/lib/AsmParser/LLToken.h +++ b/lib/AsmParser/LLToken.h @@ -96,7 +96,7 @@ namespace lltok { kw_add, kw_fadd, kw_sub, kw_fsub, kw_mul, kw_fmul, kw_udiv, kw_sdiv, kw_fdiv, kw_urem, kw_srem, kw_frem, kw_shl, kw_lshr, kw_ashr, - kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_vicmp, kw_vfcmp, + kw_and, kw_or, kw_xor, kw_icmp, kw_fcmp, kw_phi, kw_call, kw_trunc, kw_zext, kw_sext, kw_fptrunc, kw_fpext, kw_uitofp, kw_sitofp, diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index b940b9e..78f1c8f 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -987,12 +987,8 @@ bool BitcodeReader::ParseConstants() { if (OpTy->isFloatingPoint()) V = Context.getConstantExprFCmp(Record[3], Op0, Op1); - else if (!isa<VectorType>(OpTy)) - V = Context.getConstantExprICmp(Record[3], Op0, Op1); - else if (OpTy->isFPOrFPVector()) - V = Context.getConstantExprVFCmp(Record[3], Op0, Op1); else - V = Context.getConstantExprVICmp(Record[3], Op0, Op1); + V = Context.getConstantExprICmp(Record[3], Op0, Op1); break; } case bitc::CST_CODE_INLINEASM: { @@ -1632,41 +1628,27 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { break; } - case bitc::FUNC_CODE_INST_CMP: { // CMP: [opty, opval, opval, pred] - // VFCmp/VICmp - // or old form of ICmp/FCmp returning bool - unsigned OpNum = 0; - Value *LHS, *RHS; - if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || - getValue(Record, OpNum, LHS->getType(), RHS) || - OpNum+1 != Record.size()) - return Error("Invalid CMP record"); - - if (LHS->getType()->isFloatingPoint()) - I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); - else if (!isa<VectorType>(LHS->getType())) - I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); - else if (LHS->getType()->isFPOrFPVector()) - I = new VFCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); - else - I = new VICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); - break; - } + case bitc::FUNC_CODE_INST_CMP: // CMP: [opty, opval, opval, pred] + // Old form of ICmp/FCmp returning bool + // Existed to differentiate between icmp/fcmp and vicmp/vfcmp which were + // both legal on vectors but had different behaviour. case bitc::FUNC_CODE_INST_CMP2: { // CMP2: [opty, opval, opval, pred] - // Fcmp/ICmp returning bool or vector of bool + // FCmp/ICmp returning bool or vector of bool + unsigned OpNum = 0; Value *LHS, *RHS; if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || getValue(Record, OpNum, LHS->getType(), RHS) || OpNum+1 != Record.size()) - return Error("Invalid CMP2 record"); + return Error("Invalid CMP record"); if (LHS->getType()->isFPOrFPVector()) I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); - else + else I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); break; } + case bitc::FUNC_CODE_INST_GETRESULT: { // GETRESULT: [ty, val, n] if (Record.size() != 2) return Error("Invalid GETRESULT record"); diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 6dcdded..1f3fd55 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -683,16 +683,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, break; case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: - if (isa<VectorType>(C->getOperand(0)->getType()) - && (CE->getOpcode() == Instruction::ICmp - || CE->getOpcode() == Instruction::FCmp)) { - // compare returning vector of Int1Ty - assert(0 && "Unsupported constant!"); - } else { - Code = bitc::CST_CODE_CE_CMP; - } + Code = bitc::CST_CODE_CE_CMP; Record.push_back(VE.getTypeID(C->getOperand(0)->getType())); Record.push_back(VE.getValueID(C->getOperand(0))); Record.push_back(VE.getValueID(C->getOperand(1))); @@ -835,15 +826,8 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, break; case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: - if (I.getOpcode() == Instruction::ICmp - || I.getOpcode() == Instruction::FCmp) { - // compare returning Int1Ty or vector of Int1Ty - Code = bitc::FUNC_CODE_INST_CMP2; - } else { - Code = bitc::FUNC_CODE_INST_CMP; - } + // compare returning Int1Ty or vector of Int1Ty + Code = bitc::FUNC_CODE_INST_CMP2; PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(1))); Vals.push_back(cast<CmpInst>(I).getPredicate()); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index cc672ac..a2ea09c 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -2227,33 +2227,6 @@ void SelectionDAGLowering::visitFCmp(User &I) { setValue(&I, DAG.getSetCC(getCurDebugLoc(), DestVT, Op1, Op2, Condition)); } -void SelectionDAGLowering::visitVICmp(User &I) { - ICmpInst::Predicate predicate = ICmpInst::BAD_ICMP_PREDICATE; - if (VICmpInst *IC = dyn_cast<VICmpInst>(&I)) - predicate = IC->getPredicate(); - else if (ConstantExpr *IC = dyn_cast<ConstantExpr>(&I)) - predicate = ICmpInst::Predicate(IC->getPredicate()); - SDValue Op1 = getValue(I.getOperand(0)); - SDValue Op2 = getValue(I.getOperand(1)); - ISD::CondCode Opcode = getICmpCondCode(predicate); - setValue(&I, DAG.getVSetCC(getCurDebugLoc(), Op1.getValueType(), - Op1, Op2, Opcode)); -} - -void SelectionDAGLowering::visitVFCmp(User &I) { - FCmpInst::Predicate predicate = FCmpInst::BAD_FCMP_PREDICATE; - if (VFCmpInst *FC = dyn_cast<VFCmpInst>(&I)) - predicate = FC->getPredicate(); - else if (ConstantExpr *FC = dyn_cast<ConstantExpr>(&I)) - predicate = FCmpInst::Predicate(FC->getPredicate()); - SDValue Op1 = getValue(I.getOperand(0)); - SDValue Op2 = getValue(I.getOperand(1)); - ISD::CondCode Condition = getFCmpCondCode(predicate); - MVT DestVT = TLI.getValueType(I.getType()); - - setValue(&I, DAG.getVSetCC(getCurDebugLoc(), DestVT, Op1, Op2, Condition)); -} - void SelectionDAGLowering::visitSelect(User &I) { SmallVector<MVT, 4> ValueVTs; ComputeValueVTs(TLI, I.getType(), ValueVTs); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h index 057c841..b5c3d4d 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h @@ -75,8 +75,6 @@ class TruncInst; class UIToFPInst; class UnreachableInst; class UnwindInst; -class VICmpInst; -class VFCmpInst; class VAArgInst; class ZExtInst; @@ -489,8 +487,6 @@ private: void visitAShr(User &I) { visitShift(I, ISD::SRA); } void visitICmp(User &I); void visitFCmp(User &I); - void visitVICmp(User &I); - void visitVFCmp(User &I); // Visit the conversion instructions void visitTrunc(User &I); void visitZExt(User &I); diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index cd83778..b207bcc 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -2056,7 +2056,7 @@ static SDValue LowerVSETCC(SDValue Op, SelectionDAG &DAG) { case ISD::SETUGE: Opc = ARMISD::VCGEU; break; } - // Detect VTST (Vector Test Bits) = vicmp ne (and (op0, op1), zero). + // Detect VTST (Vector Test Bits) = icmp ne (and (op0, op1), zero). if (Opc == ARMISD::VCEQ) { SDValue AndOp; diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index f4fe15e..962ba71 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -224,7 +224,7 @@ Expression::ExpressionOpcode ValueTable::getOpcode(BinaryOperator* BO) { } Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) { - if (isa<ICmpInst>(C) || isa<VICmpInst>(C)) { + if (isa<ICmpInst>(C)) { switch (C->getPredicate()) { default: // THIS SHOULD NEVER HAPPEN assert(0 && "Comparison with unknown predicate?"); @@ -239,25 +239,25 @@ Expression::ExpressionOpcode ValueTable::getOpcode(CmpInst* C) { case ICmpInst::ICMP_SLT: return Expression::ICMPSLT; case ICmpInst::ICMP_SLE: return Expression::ICMPSLE; } - } - assert((isa<FCmpInst>(C) || isa<VFCmpInst>(C)) && "Unknown compare"); - switch (C->getPredicate()) { - default: // THIS SHOULD NEVER HAPPEN - assert(0 && "Comparison with unknown predicate?"); - case FCmpInst::FCMP_OEQ: return Expression::FCMPOEQ; - case FCmpInst::FCMP_OGT: return Expression::FCMPOGT; - case FCmpInst::FCMP_OGE: return Expression::FCMPOGE; - case FCmpInst::FCMP_OLT: return Expression::FCMPOLT; - case FCmpInst::FCMP_OLE: return Expression::FCMPOLE; - case FCmpInst::FCMP_ONE: return Expression::FCMPONE; - case FCmpInst::FCMP_ORD: return Expression::FCMPORD; - case FCmpInst::FCMP_UNO: return Expression::FCMPUNO; - case FCmpInst::FCMP_UEQ: return Expression::FCMPUEQ; - case FCmpInst::FCMP_UGT: return Expression::FCMPUGT; - case FCmpInst::FCMP_UGE: return Expression::FCMPUGE; - case FCmpInst::FCMP_ULT: return Expression::FCMPULT; - case FCmpInst::FCMP_ULE: return Expression::FCMPULE; - case FCmpInst::FCMP_UNE: return Expression::FCMPUNE; + } else { + switch (C->getPredicate()) { + default: // THIS SHOULD NEVER HAPPEN + assert(0 && "Comparison with unknown predicate?"); + case FCmpInst::FCMP_OEQ: return Expression::FCMPOEQ; + case FCmpInst::FCMP_OGT: return Expression::FCMPOGT; + case FCmpInst::FCMP_OGE: return Expression::FCMPOGE; + case FCmpInst::FCMP_OLT: return Expression::FCMPOLT; + case FCmpInst::FCMP_OLE: return Expression::FCMPOLE; + case FCmpInst::FCMP_ONE: return Expression::FCMPONE; + case FCmpInst::FCMP_ORD: return Expression::FCMPORD; + case FCmpInst::FCMP_UNO: return Expression::FCMPUNO; + case FCmpInst::FCMP_UEQ: return Expression::FCMPUEQ; + case FCmpInst::FCMP_UGT: return Expression::FCMPUGT; + case FCmpInst::FCMP_UGE: return Expression::FCMPUGE; + case FCmpInst::FCMP_ULT: return Expression::FCMPULT; + case FCmpInst::FCMP_ULE: return Expression::FCMPULE; + case FCmpInst::FCMP_UNE: return Expression::FCMPUNE; + } } } diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 3aab0cc..e019e6c 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1058,7 +1058,7 @@ static ICmpInst::Predicate evaluateICmpRelation(const Constant *V1, R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2)); if (R && !R->isZero()) return pred; - pred = isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; + pred = isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2)); if (R && !R->isZero()) return pred; @@ -1257,30 +1257,22 @@ static ICmpInst::Predicate evaluateICmpRelation(const Constant *V1, Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, const Constant *C1, const Constant *C2) { + const Type *ResultTy; + if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) + ResultTy = VectorType::get(Type::Int1Ty, VT->getNumElements()); + else + ResultTy = Type::Int1Ty; + // Fold FCMP_FALSE/FCMP_TRUE unconditionally. - if (pred == FCmpInst::FCMP_FALSE) { - if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) - return Constant::getNullValue(VectorType::getInteger(VT)); - else - return ConstantInt::getFalse(); - } - - if (pred == FCmpInst::FCMP_TRUE) { - if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) - return Constant::getAllOnesValue(VectorType::getInteger(VT)); - else - return ConstantInt::getTrue(); - } - + if (pred == FCmpInst::FCMP_FALSE) + return Constant::getNullValue(ResultTy); + + if (pred == FCmpInst::FCMP_TRUE) + return Constant::getAllOnesValue(ResultTy); + // Handle some degenerate cases first - if (isa<UndefValue>(C1) || isa<UndefValue>(C2)) { - // vicmp/vfcmp -> [vector] undef - if (const VectorType *VTy = dyn_cast<VectorType>(C1->getType())) - return UndefValue::get(VectorType::getInteger(VTy)); - - // icmp/fcmp -> i1 undef - return UndefValue::get(Type::Int1Ty); - } + if (isa<UndefValue>(C1) || isa<UndefValue>(C2)) + return UndefValue::get(ResultTy); // No compile-time operations on this type yet. if (C1->getType() == Type::PPC_FP128Ty) @@ -1375,35 +1367,11 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, // If we can constant fold the comparison of each element, constant fold // the whole vector comparison. SmallVector<Constant*, 4> ResElts; - const Type *InEltTy = C1Elts[0]->getType(); - bool isFP = InEltTy->isFloatingPoint(); - const Type *ResEltTy = InEltTy; - if (isFP) - ResEltTy = IntegerType::get(InEltTy->getPrimitiveSizeInBits()); - for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) { // Compare the elements, producing an i1 result or constant expr. - Constant *C; - if (isFP) - C = ConstantExpr::getFCmp(pred, C1Elts[i], C2Elts[i]); - else - C = ConstantExpr::getICmp(pred, C1Elts[i], C2Elts[i]); - - // If it is a bool or undef result, convert to the dest type. - if (ConstantInt *CI = dyn_cast<ConstantInt>(C)) { - if (CI->isZero()) - ResElts.push_back(Constant::getNullValue(ResEltTy)); - else - ResElts.push_back(Constant::getAllOnesValue(ResEltTy)); - } else if (isa<UndefValue>(C)) { - ResElts.push_back(UndefValue::get(ResEltTy)); - } else { - break; - } + ResElts.push_back(ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i])); } - - if (ResElts.size() == C1Elts.size()) - return ConstantVector::get(&ResElts[0], ResElts.size()); + return ConstantVector::get(&ResElts[0], ResElts.size()); } if (C1->getType()->isFloatingPoint()) { @@ -1461,16 +1429,9 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, } // If we evaluated the result, return it now. - if (Result != -1) { - if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) { - if (Result == 0) - return Constant::getNullValue(VectorType::getInteger(VT)); - else - return Constant::getAllOnesValue(VectorType::getInteger(VT)); - } + if (Result != -1) return ConstantInt::get(Type::Int1Ty, Result); - } - + } else { // Evaluate the relation between the two constants, per the predicate. int Result = -1; // -1 = unknown, 0 = known false, 1 = known true. @@ -1545,18 +1506,11 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, } // If we evaluated the result, return it now. - if (Result != -1) { - if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) { - if (Result == 0) - return Constant::getNullValue(VT); - else - return Constant::getAllOnesValue(VT); - } + if (Result != -1) return ConstantInt::get(Type::Int1Ty, Result); - } if (!isa<ConstantExpr>(C1) && isa<ConstantExpr>(C2)) { - // If C2 is a constant expr and C1 isn't, flop them around and fold the + // If C2 is a constant expr and C1 isn't, flip them around and fold the // other way if possible. switch (pred) { case ICmpInst::ICMP_EQ: @@ -1582,7 +1536,7 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, } } return 0; -} + } Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, Constant* const *Idxs, diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index a350031..5ee386d 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -814,8 +814,7 @@ bool ConstantExpr::isCast() const { } bool ConstantExpr::isCompare() const { - return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp || - getOpcode() == Instruction::VICmp || getOpcode() == Instruction::VFCmp; + return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp; } bool ConstantExpr::hasIndices() const { @@ -904,9 +903,7 @@ Constant *ConstantExpr::getXor(Constant *C1, Constant *C2) { } unsigned ConstantExpr::getPredicate() const { assert(getOpcode() == Instruction::FCmp || - getOpcode() == Instruction::ICmp || - getOpcode() == Instruction::VFCmp || - getOpcode() == Instruction::VICmp); + getOpcode() == Instruction::ICmp); return ((const CompareConstantExpr*)this)->predicate; } Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) { @@ -1022,8 +1019,6 @@ getWithOperands(Constant* const *Ops, unsigned NumOps) const { return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], NumOps-1); case Instruction::ICmp: case Instruction::FCmp: - case Instruction::VICmp: - case Instruction::VFCmp: return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]); default: assert(getNumOperands() == 2 && "Must be binary operator?"); @@ -1944,12 +1939,6 @@ namespace llvm { if (V.opcode == Instruction::FCmp) return new CompareConstantExpr(Ty, Instruction::FCmp, V.predicate, V.operands[0], V.operands[1]); - if (V.opcode == Instruction::VICmp) - return new CompareConstantExpr(Ty, Instruction::VICmp, V.predicate, - V.operands[0], V.operands[1]); - if (V.opcode == Instruction::VFCmp) - return new CompareConstantExpr(Ty, Instruction::VFCmp, V.predicate, - V.operands[0], V.operands[1]); assert(0 && "Invalid ConstantExpr!"); return 0; } @@ -2297,7 +2286,6 @@ Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, Constant *ConstantExpr::getCompareTy(unsigned short predicate, Constant *C1, Constant *C2) { - bool isVectorType = C1->getType()->getTypeID() == Type::VectorTyID; switch (predicate) { default: assert(0 && "Invalid CmpInst predicate"); case CmpInst::FCMP_FALSE: case CmpInst::FCMP_OEQ: case CmpInst::FCMP_OGT: @@ -2306,14 +2294,13 @@ Constant *ConstantExpr::getCompareTy(unsigned short predicate, case CmpInst::FCMP_UEQ: case CmpInst::FCMP_UGT: case CmpInst::FCMP_UGE: case CmpInst::FCMP_ULT: case CmpInst::FCMP_ULE: case CmpInst::FCMP_UNE: case CmpInst::FCMP_TRUE: - return isVectorType ? getVFCmp(predicate, C1, C2) - : getFCmp(predicate, C1, C2); + return getFCmp(predicate, C1, C2); + case CmpInst::ICMP_EQ: case CmpInst::ICMP_NE: case CmpInst::ICMP_UGT: case CmpInst::ICMP_UGE: case CmpInst::ICMP_ULT: case CmpInst::ICMP_ULE: case CmpInst::ICMP_SGT: case CmpInst::ICMP_SGE: case CmpInst::ICMP_SLT: case CmpInst::ICMP_SLE: - return isVectorType ? getVICmp(predicate, C1, C2) - : getICmp(predicate, C1, C2); + return getICmp(predicate, C1, C2); } } @@ -2488,102 +2475,6 @@ ConstantExpr::getFCmp(unsigned short pred, Constant* LHS, Constant* RHS) { return ExprConstants->getOrCreate(Type::Int1Ty, Key); } -Constant * -ConstantExpr::getVICmp(unsigned short pred, Constant* LHS, Constant* RHS) { - assert(isa<VectorType>(LHS->getType()) && LHS->getType() == RHS->getType() && - "Tried to create vicmp operation on non-vector type!"); - assert(pred >= ICmpInst::FIRST_ICMP_PREDICATE && - pred <= ICmpInst::LAST_ICMP_PREDICATE && "Invalid VICmp Predicate"); - - const VectorType *VTy = cast<VectorType>(LHS->getType()); - const Type *EltTy = VTy->getElementType(); - unsigned NumElts = VTy->getNumElements(); - - // See if we can fold the element-wise comparison of the LHS and RHS. - SmallVector<Constant *, 16> LHSElts, RHSElts; - LHS->getVectorElements(LHSElts); - RHS->getVectorElements(RHSElts); - - if (!LHSElts.empty() && !RHSElts.empty()) { - SmallVector<Constant *, 16> Elts; - for (unsigned i = 0; i != NumElts; ++i) { - Constant *FC = ConstantFoldCompareInstruction(pred, LHSElts[i], - RHSElts[i]); - if (ConstantInt *FCI = dyn_cast_or_null<ConstantInt>(FC)) { - if (FCI->getZExtValue()) - Elts.push_back(ConstantInt::getAllOnesValue(EltTy)); - else - Elts.push_back(ConstantInt::get(EltTy, 0ULL)); - } else if (FC && isa<UndefValue>(FC)) { - Elts.push_back(UndefValue::get(EltTy)); - } else { - break; - } - } - if (Elts.size() == NumElts) - return ConstantVector::get(&Elts[0], Elts.size()); - } - - // Look up the constant in the table first to ensure uniqueness - std::vector<Constant*> ArgVec; - ArgVec.push_back(LHS); - ArgVec.push_back(RHS); - // Get the key type with both the opcode and predicate - const ExprMapKeyType Key(Instruction::VICmp, ArgVec, pred); - - // Implicitly locked. - return ExprConstants->getOrCreate(LHS->getType(), Key); -} - -Constant * -ConstantExpr::getVFCmp(unsigned short pred, Constant* LHS, Constant* RHS) { - assert(isa<VectorType>(LHS->getType()) && - "Tried to create vfcmp operation on non-vector type!"); - assert(LHS->getType() == RHS->getType()); - assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid VFCmp Predicate"); - - const VectorType *VTy = cast<VectorType>(LHS->getType()); - unsigned NumElts = VTy->getNumElements(); - const Type *EltTy = VTy->getElementType(); - const Type *REltTy = IntegerType::get(EltTy->getPrimitiveSizeInBits()); - const Type *ResultTy = VectorType::get(REltTy, NumElts); - - // See if we can fold the element-wise comparison of the LHS and RHS. - SmallVector<Constant *, 16> LHSElts, RHSElts; - LHS->getVectorElements(LHSElts); - RHS->getVectorElements(RHSElts); - - if (!LHSElts.empty() && !RHSElts.empty()) { - SmallVector<Constant *, 16> Elts; - for (unsigned i = 0; i != NumElts; ++i) { - Constant *FC = ConstantFoldCompareInstruction(pred, LHSElts[i], - RHSElts[i]); - if (ConstantInt *FCI = dyn_cast_or_null<ConstantInt>(FC)) { - if (FCI->getZExtValue()) - Elts.push_back(ConstantInt::getAllOnesValue(REltTy)); - else - Elts.push_back(ConstantInt::get(REltTy, 0ULL)); - } else if (FC && isa<UndefValue>(FC)) { - Elts.push_back(UndefValue::get(REltTy)); - } else { - break; - } - } - if (Elts.size() == NumElts) - return ConstantVector::get(&Elts[0], Elts.size()); - } - - // Look up the constant in the table first to ensure uniqueness - std::vector<Constant*> ArgVec; - ArgVec.push_back(LHS); - ArgVec.push_back(RHS); - // Get the key type with both the opcode and predicate - const ExprMapKeyType Key(Instruction::VFCmp, ArgVec, pred); - - // Implicitly locked. - return ExprConstants->getOrCreate(ResultTy, Key); -} - Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val, Constant *Idx) { if (Constant *FC = ConstantFoldExtractElementInstruction(Val, Idx)) @@ -2992,13 +2883,9 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, if (C2 == From) C2 = To; if (getOpcode() == Instruction::ICmp) Replacement = ConstantExpr::getICmp(getPredicate(), C1, C2); - else if (getOpcode() == Instruction::FCmp) - Replacement = ConstantExpr::getFCmp(getPredicate(), C1, C2); - else if (getOpcode() == Instruction::VICmp) - Replacement = ConstantExpr::getVICmp(getPredicate(), C1, C2); else { - assert(getOpcode() == Instruction::VFCmp); - Replacement = ConstantExpr::getVFCmp(getPredicate(), C1, C2); + assert(getOpcode() == Instruction::FCmp); + Replacement = ConstantExpr::getFCmp(getPredicate(), C1, C2); } } else if (getNumOperands() == 2) { Constant *C1 = getOperand(0); diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index e0764e4..4fc9f3c 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -143,8 +143,6 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { // Other instructions... case ICmp: return "icmp"; case FCmp: return "fcmp"; - case VICmp: return "vicmp"; - case VFCmp: return "vfcmp"; case PHI: return "phi"; case Select: return "select"; case Call: return "call"; diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 6a6424d..8d14766 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2583,16 +2583,8 @@ CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, InsertBefore); } - if (Op == Instruction::FCmp) { - return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertBefore); - } - if (Op == Instruction::VICmp) { - return new VICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertBefore); - } - return new VFCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertBefore); + return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, + InsertBefore); } CmpInst * @@ -2602,16 +2594,8 @@ CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, InsertAtEnd); } - if (Op == Instruction::FCmp) { - return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertAtEnd); - } - if (Op == Instruction::VICmp) { - return new VICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertAtEnd); - } - return new VFCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, - InsertAtEnd); + return new FCmpInst(CmpInst::Predicate(predicate), S1, S2, Name, + InsertAtEnd); } void CmpInst::swapOperands() { @@ -2951,13 +2935,6 @@ ICmpInst* ICmpInst::clone() const { return new ICmpInst(getPredicate(), Op<0>(), Op<1>()); } -VFCmpInst* VFCmpInst::clone() const { - return new VFCmpInst(getPredicate(), Op<0>(), Op<1>()); -} -VICmpInst* VICmpInst::clone() const { - return new VICmpInst(getPredicate(), Op<0>(), Op<1>()); -} - ExtractValueInst *ExtractValueInst::clone() const { return new ExtractValueInst(*this); } diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp index a96d2d9..422798d 100644 --- a/lib/VMCore/LLVMContext.cpp +++ b/lib/VMCore/LLVMContext.cpp @@ -312,16 +312,6 @@ Constant* LLVMContext::getConstantExprFCmp(unsigned short pred, Constant* LHS, return ConstantExpr::getFCmp(pred, LHS, RHS); } -Constant* LLVMContext::getConstantExprVICmp(unsigned short pred, Constant* LHS, - Constant* RHS) { - return ConstantExpr::getVICmp(pred, LHS, RHS); -} - -Constant* LLVMContext::getConstantExprVFCmp(unsigned short pred, Constant* LHS, - Constant* RHS) { - return ConstantExpr::getVFCmp(pred, LHS, RHS); -} - Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) { return ConstantExpr::getShl(C1, C2); } |