From: Nick Lewycky Date: Wed, 8 Jul 2009 03:04:38 +0000 (+0000) Subject: Remove the vicmp and vfcmp instructions. Because we never had a release with X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=7f6aa2b162e5daaf7b9ccf05d749597d3d7cf460 Remove the vicmp and vfcmp instructions. Because we never had a release with these instructions, no autoupgrade or backwards compatibility support is provided. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74991 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LangRef.html b/docs/LangRef.html index c57518befc0..416b105cd72 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -155,8 +155,6 @@
  1. 'icmp' Instruction
  2. 'fcmp' Instruction
  3. -
  4. 'vicmp' Instruction
  5. -
  6. 'vfcmp' Instruction
  7. 'phi' Instruction
  8. 'select' Instruction
  9. 'call' Instruction
  10. @@ -2042,12 +2040,6 @@ following is the syntax for constant expressions:

    fcmp COND ( VAL1, VAL2 )
    Performs the fcmp operation on constants.
    -
    vicmp COND ( VAL1, VAL2 )
    -
    Performs the vicmp operation on constants.
    - -
    vfcmp COND ( VAL1, VAL2 )
    -
    Performs the vfcmp operation on constants.
    -
    extractelement ( VAL, IDX )
    Perform the extractelement @@ -4504,109 +4496,6 @@ always yields an i1 result, as follows:

    - - -
    -
    Syntax:
    -
      <result> = vicmp <cond> <ty> <op1>, <op2>   ; yields {ty}:result
    -
    -
    Overview:
    -

    The 'vicmp' instruction returns an integer vector value based on -element-wise comparison of its two integer vector operands.

    -
    Arguments:
    -

    The 'vicmp' instruction takes three operands. The first operand is -the condition code indicating the kind of comparison to perform. It is not -a value, just a keyword. The possible condition code are:

    -
      -
    1. eq: equal
    2. -
    3. ne: not equal
    4. -
    5. ugt: unsigned greater than
    6. -
    7. uge: unsigned greater or equal
    8. -
    9. ult: unsigned less than
    10. -
    11. ule: unsigned less or equal
    12. -
    13. sgt: signed greater than
    14. -
    15. sge: signed greater or equal
    16. -
    17. slt: signed less than
    18. -
    19. sle: signed less or equal
    20. -
    -

    The remaining two arguments must be vector or -integer typed. They must also be identical types.

    -
    Semantics:
    -

    The 'vicmp' instruction compares op1 and op2 -according to the condition code given as cond. The comparison yields a -vector of integer result, of -identical type as the values being compared. The most significant bit in each -element is 1 if the element-wise comparison evaluates to true, and is 0 -otherwise. All other bits of the result are undefined. The condition codes -are evaluated identically to the 'icmp' -instruction.

    - -
    Example:
    -
    -  <result> = vicmp eq <2 x i32> < i32 4, i32 0>, < i32 5, i32 0>   ; yields: result=<2 x i32> < i32 0, i32 -1 >
    -  <result> = vicmp ult <2 x i8 > < i8 1, i8 2>, < i8 2, i8 2 >        ; yields: result=<2 x i8> < i8 -1, i8 0 >
    -
    -
    - - - -
    -
    Syntax:
    -
      <result> = vfcmp <cond> <ty> <op1>, <op2>
    -
    Overview:
    -

    The 'vfcmp' instruction returns an integer vector value based on -element-wise comparison of its two floating point vector operands. The output -elements have the same width as the input elements.

    -
    Arguments:
    -

    The 'vfcmp' instruction takes three operands. The first operand is -the condition code indicating the kind of comparison to perform. It is not -a value, just a keyword. The possible condition code are:

    -
      -
    1. false: no comparison, always returns false
    2. -
    3. oeq: ordered and equal
    4. -
    5. ogt: ordered and greater than
    6. -
    7. oge: ordered and greater than or equal
    8. -
    9. olt: ordered and less than
    10. -
    11. ole: ordered and less than or equal
    12. -
    13. one: ordered and not equal
    14. -
    15. ord: ordered (no nans)
    16. -
    17. ueq: unordered or equal
    18. -
    19. ugt: unordered or greater than
    20. -
    21. uge: unordered or greater than or equal
    22. -
    23. ult: unordered or less than
    24. -
    25. ule: unordered or less than or equal
    26. -
    27. une: unordered or not equal
    28. -
    29. uno: unordered (either nans)
    30. -
    31. true: no comparison, always returns true
    32. -
    -

    The remaining two arguments must be vector of -floating point typed. They must also be identical -types.

    -
    Semantics:
    -

    The 'vfcmp' instruction compares op1 and op2 -according to the condition code given as cond. The comparison yields a -vector of integer result, with -an identical number of elements as the values being compared, and each element -having identical with to the width of the floating point elements. The most -significant bit in each element is 1 if the element-wise comparison evaluates to -true, and is 0 otherwise. All other bits of the result are undefined. The -condition codes are evaluated identically to the -'fcmp' instruction.

    - -
    Example:
    -
    -  ; yields: result=<2 x i32> < i32 0, i32 -1 >
    -  <result> = vfcmp oeq <2 x float> < float 4, float 0 >, < float 5, float 0 >
    -  
    -  ; yields: result=<2 x i64> < i64 -1, i64 0 >
    -  <result> = vfcmp ult <2 x double> < double 1, double 2 >, < double 2, double 2>
    -
    -
    -
    'phi' Instruction diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index e0eaf9b5cba..9d8577380ba 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -341,8 +341,6 @@ void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle); macro(CmpInst) \ macro(FCmpInst) \ macro(ICmpInst) \ - macro(VFCmpInst) \ - macro(VICmpInst) \ macro(ExtractElementInst) \ macro(GetElementPtrInst) \ macro(InsertElementInst) \ diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 1ede69dee16..c3a1bc1d8a8 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -210,7 +210,8 @@ namespace bitc { FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n] FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands] FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands] - // fcmp/icmp returning Int1TY or vector of Int1Ty, NOT for vicmp/vfcmp + // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to + // support legacy vicmp/vfcmp instructions. FUNC_CODE_INST_CMP2 = 28, // CMP2: [opty, opval, opval, pred] // new select on i1 or [N x i1] FUNC_CODE_INST_VSELECT = 29 // VSELECT: [ty,opval,opval,predty,pred] diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index da69d25cf62..09750668a12 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -710,8 +710,7 @@ public: /// static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); - /// @brief Return an ICmp, FCmp, VICmp, or VFCmp comparison operator constant - /// expression. + /// @brief Return an ICmp or FCmp comparison operator constant expression. static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2); /// ConstantExpr::get* - Return some common constants without having to @@ -737,8 +736,6 @@ public: static Constant *getXor(Constant *C1, Constant *C2); static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS); - static Constant *getVICmp(unsigned short pred, Constant *LHS, Constant *RHS); - static Constant *getVFCmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getShl(Constant *C1, Constant *C2); static Constant *getLShr(Constant *C1, Constant *C2); static Constant *getAShr(Constant *C1, Constant *C2); diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 1eab983da68..0a018de5e9b 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -655,14 +655,12 @@ public: static inline bool classof(const CmpInst *) { return true; } static inline bool classof(const Instruction *I) { return I->getOpcode() == Instruction::ICmp || - I->getOpcode() == Instruction::FCmp || - I->getOpcode() == Instruction::VICmp || - I->getOpcode() == Instruction::VFCmp; + I->getOpcode() == Instruction::FCmp; } static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } - /// @brief Create a result type for fcmp/icmp (but not vicmp/vfcmp) + /// @brief Create a result type for fcmp/icmp static const Type* makeCmpResultType(const Type* opnd_type) { if (const VectorType* vt = dyn_cast(opnd_type)) { return VectorType::get(Type::Int1Ty, vt->getNumElements()); diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def index 98fda777054..e603c1257ef 100644 --- a/include/llvm/Instruction.def +++ b/include/llvm/Instruction.def @@ -169,10 +169,8 @@ HANDLE_OTHER_INST(52, InsertElement, InsertElementInst) // insert into vector HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate HANDLE_OTHER_INST(55, InsertValue, InsertValueInst) // insert into aggregate -HANDLE_OTHER_INST(56, VICmp , VICmpInst ) // Vec Int comparison instruction. -HANDLE_OTHER_INST(57, VFCmp , VFCmpInst ) // Vec FP point comparison instr. - LAST_OTHER_INST(57) + LAST_OTHER_INST(55) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 4419fbd6a9d..aef77f0a93d 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -861,118 +861,6 @@ public: }; -//===----------------------------------------------------------------------===// -// VICmpInst Class -//===----------------------------------------------------------------------===// - -/// This instruction compares its operands according to the predicate given -/// to the constructor. It only operates on vectors of integers. -/// The operands must be identical types. -/// @brief Represents a vector integer comparison operator. -class VICmpInst: public CmpInst { -public: - /// @brief Constructor with insert-before-instruction semantics. - VICmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr = "", ///< Name of the instruction - Instruction *InsertBefore = 0 ///< Where to insert - ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr, - InsertBefore) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid VICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VICmp instruction are not of the same type!"); - } - - /// @brief Constructor with insert-at-block-end semantics. - VICmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr, ///< Name of the instruction - BasicBlock *InsertAtEnd ///< Block to insert into. - ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr, - InsertAtEnd) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid VICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VICmp instruction are not of the same type!"); - } - - /// @brief Return the predicate for this instruction. - Predicate getPredicate() const { return Predicate(SubclassData); } - - virtual VICmpInst *clone() const; - - // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const VICmpInst *) { return true; } - static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::VICmp; - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - -//===----------------------------------------------------------------------===// -// VFCmpInst Class -//===----------------------------------------------------------------------===// - -/// This instruction compares its operands according to the predicate given -/// to the constructor. It only operates on vectors of floating point values. -/// The operands must be identical types. -/// @brief Represents a vector floating point comparison operator. -class VFCmpInst: public CmpInst { -public: - /// @brief Constructor with insert-before-instruction semantics. - VFCmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr = "", ///< Name of the instruction - Instruction *InsertBefore = 0 ///< Where to insert - ) : CmpInst(VectorType::getInteger(cast(LHS->getType())), - Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertBefore) { - assert(pred <= CmpInst::LAST_FCMP_PREDICATE && - "Invalid VFCmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VFCmp instruction are not of the same type!"); - } - - /// @brief Constructor with insert-at-block-end semantics. - VFCmpInst( - Predicate pred, ///< The predicate to use for the comparison - Value *LHS, ///< The left-hand-side of the expression - Value *RHS, ///< The right-hand-side of the expression - const std::string &NameStr, ///< Name of the instruction - BasicBlock *InsertAtEnd ///< Block to insert into. - ) : CmpInst(VectorType::getInteger(cast(LHS->getType())), - Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertAtEnd) { - assert(pred <= CmpInst::LAST_FCMP_PREDICATE && - "Invalid VFCmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to VFCmp instruction are not of the same type!"); - } - - /// @brief Return the predicate for this instruction. - Predicate getPredicate() const { return Predicate(SubclassData); } - - virtual VFCmpInst *clone() const; - - /// @brief Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const VFCmpInst *) { return true; } - static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::VFCmp; - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - //===----------------------------------------------------------------------===// // CallInst Class //===----------------------------------------------------------------------===// diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 7420a742112..60da89eb4ac 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -145,10 +145,6 @@ public: Constant* RHS); Constant* getConstantExprFCmp(unsigned short pred, Constant* LHS, Constant* RHS); - Constant* getConstantExprVICmp(unsigned short pred, Constant* LHS, - Constant* RHS); - Constant* getConstantExprVFCmp(unsigned short pred, Constant* LHS, - Constant* RHS); Constant* getConstantExprShl(Constant* C1, Constant* C2); Constant* getConstantExprLShr(Constant* C1, Constant* C2); Constant* getConstantExprAShr(Constant* C1, Constant* C2); diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h index 35065a06086..71368f145b4 100644 --- a/include/llvm/Support/ConstantFolder.h +++ b/include/llvm/Support/ConstantFolder.h @@ -154,14 +154,6 @@ public: Constant *RHS) const { return ConstantExpr::getCompare(P, LHS, RHS); } - Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return ConstantExpr::getCompare(P, LHS, RHS); - } - Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return ConstantExpr::getCompare(P, LHS, RHS); - } //===--------------------------------------------------------------------===// // Other Instructions diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index f05ee861488..f92f8654a57 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -570,21 +570,6 @@ public: return Insert(new FCmpInst(P, LHS, RHS), Name); } - Value *CreateVICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return Folder.CreateVICmp(P, LC, RC); - return Insert(new VICmpInst(P, LHS, RHS), Name); - } - Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return Folder.CreateVFCmp(P, LC, RC); - return Insert(new VFCmpInst(P, LHS, RHS), Name); - } - //===--------------------------------------------------------------------===// // Instruction creation methods: Other Instructions //===--------------------------------------------------------------------===// diff --git a/include/llvm/Support/InstVisitor.h b/include/llvm/Support/InstVisitor.h index 597cc9d9054..768f4877ade 100644 --- a/include/llvm/Support/InstVisitor.h +++ b/include/llvm/Support/InstVisitor.h @@ -165,8 +165,6 @@ public: RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} - RetTy visitVICmpInst(VICmpInst &I) { DELEGATE(CmpInst);} - RetTy visitVFCmpInst(VFCmpInst &I) { DELEGATE(CmpInst);} RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); } diff --git a/include/llvm/Support/NoFolder.h b/include/llvm/Support/NoFolder.h index a49cf842406..40c1996c319 100644 --- a/include/llvm/Support/NoFolder.h +++ b/include/llvm/Support/NoFolder.h @@ -143,12 +143,6 @@ public: Value *CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const { return new FCmpInst(P, LHS, RHS); } - Value *CreateVICmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const { - return new VICmpInst(P, LHS, RHS); - } - Value *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const { - return new VFCmpInst(P, LHS, RHS); - } //===--------------------------------------------------------------------===// // Other Instructions diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index a1b63aab84b..db2a31a7d21 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -179,14 +179,6 @@ public: Constant *RHS) const { return Fold(ConstantExpr::getCompare(P, LHS, RHS)); } - Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return Fold(ConstantExpr::getCompare(P, LHS, RHS)); - } - Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, - Constant *RHS) const { - return Fold(ConstantExpr::getCompare(P, LHS, RHS)); - } //===--------------------------------------------------------------------===// // Other Instructions diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 7ebfec3dff4..ffdc52ce743 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 cab94174de4..10e5a60ec9e 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 49509d52245..8c30ab5a701 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(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(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(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(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(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(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 cff89f8e472..b5194ad83f3 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 b940b9e3ec0..78f1c8fd8b8 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(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(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 6dcddedef1c..1f3fd551e6c 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(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(I).getPredicate()); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index cc672ac22c3..a2ea09cee2f 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(&I)) - predicate = IC->getPredicate(); - else if (ConstantExpr *IC = dyn_cast(&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(&I)) - predicate = FC->getPredicate(); - else if (ConstantExpr *FC = dyn_cast(&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 ValueVTs; ComputeValueVTs(TLI, I.getType(), ValueVTs); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h index 057c8410da0..b5c3d4db0af 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 cd837786778..b207bcc356d 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 f4fe15e0e52..962ba71dc74 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(C) || isa(C)) { + if (isa(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(C) || isa(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 3aab0cce37e..e019e6c29c1 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(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(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(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(C1->getType())) - return Constant::getNullValue(VectorType::getInteger(VT)); - else - return ConstantInt::getFalse(); - } - - if (pred == FCmpInst::FCMP_TRUE) { - if (const VectorType *VT = dyn_cast(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(C1) || isa(C2)) { - // vicmp/vfcmp -> [vector] undef - if (const VectorType *VTy = dyn_cast(C1->getType())) - return UndefValue::get(VectorType::getInteger(VTy)); - - // icmp/fcmp -> i1 undef - return UndefValue::get(Type::Int1Ty); - } + if (isa(C1) || isa(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 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(C)) { - if (CI->isZero()) - ResElts.push_back(Constant::getNullValue(ResEltTy)); - else - ResElts.push_back(Constant::getAllOnesValue(ResEltTy)); - } else if (isa(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(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(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(C1) && isa(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 a3500316278..5ee386d67be 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(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(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 LHSElts, RHSElts; - LHS->getVectorElements(LHSElts); - RHS->getVectorElements(RHSElts); - - if (!LHSElts.empty() && !RHSElts.empty()) { - SmallVector Elts; - for (unsigned i = 0; i != NumElts; ++i) { - Constant *FC = ConstantFoldCompareInstruction(pred, LHSElts[i], - RHSElts[i]); - if (ConstantInt *FCI = dyn_cast_or_null(FC)) { - if (FCI->getZExtValue()) - Elts.push_back(ConstantInt::getAllOnesValue(EltTy)); - else - Elts.push_back(ConstantInt::get(EltTy, 0ULL)); - } else if (FC && isa(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 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(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(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 LHSElts, RHSElts; - LHS->getVectorElements(LHSElts); - RHS->getVectorElements(RHSElts); - - if (!LHSElts.empty() && !RHSElts.empty()) { - SmallVector Elts; - for (unsigned i = 0; i != NumElts; ++i) { - Constant *FC = ConstantFoldCompareInstruction(pred, LHSElts[i], - RHSElts[i]); - if (ConstantInt *FCI = dyn_cast_or_null(FC)) { - if (FCI->getZExtValue()) - Elts.push_back(ConstantInt::getAllOnesValue(REltTy)); - else - Elts.push_back(ConstantInt::get(REltTy, 0ULL)); - } else if (FC && isa(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 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 e0764e494b2..4fc9f3c7e77 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 6a6424d39dd..8d14766c21a 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 a96d2d9ecf7..422798d220f 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); } diff --git a/test/Assembler/vector-cmp.ll b/test/Assembler/vector-cmp.ll index 383c0faf620..e4d35d9c982 100644 --- a/test/Assembler/vector-cmp.ll +++ b/test/Assembler/vector-cmp.ll @@ -1,16 +1,16 @@ -; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep {global.*vicmp slt} +; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep {global.*icmp slt} ; PR2317 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i686-apple-darwin9.2.2" -define <4 x i32> @foo(<4 x float> %a, <4 x float> %b) nounwind { +define <4 x i1> @foo(<4 x float> %a, <4 x float> %b) nounwind { entry: - %cmp = vfcmp olt <4 x float> %a, %b ; <4 x i32> [#uses=1] - ret <4 x i32> %cmp + %cmp = fcmp olt <4 x float> %a, %b ; <4 x i32> [#uses=1] + ret <4 x i1> %cmp } -global <4 x i32> vicmp slt ( <4 x i32> , <4 x i32> ) ; +global <4 x i1> icmp slt ( <4 x i32> , <4 x i32> ) ; @B = external global i32; -global <4 x i32> vicmp slt ( <4 x i32> , <4 x i32> ) ; +global <4 x i1> icmp slt ( <4 x i32> , <4 x i32> ) ; diff --git a/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll b/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll index 4c714632048..2cb01ba446d 100644 --- a/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll +++ b/test/Transforms/ConstProp/2008-07-07-VectorCompare.ll @@ -1,28 +1,28 @@ ; RUN: llvm-as < %s | opt -constprop -disable-output ; PR2529 -define <4 x i32> @test1(i32 %argc, i8** %argv) { +define <4 x i1> @test1(i32 %argc, i8** %argv) { entry: - %foo = vicmp slt <4 x i32> undef, - ret <4 x i32> %foo + %foo = icmp slt <4 x i32> undef, + ret <4 x i1> %foo } -define <4 x i32> @test2(i32 %argc, i8** %argv) { +define <4 x i1> @test2(i32 %argc, i8** %argv) { entry: - %foo = vicmp slt <4 x i32> , - ret <4 x i32> %foo + ret <4 x i1> %foo } -define <4 x i32> @test3() { - %foo = vfcmp ueq <4 x float> @test3() { + %foo = fcmp ueq <4 x float> , - ret <4 x i32> %foo + ret <4 x i1> %foo } -define <4 x i32> @test4() { - %foo = vfcmp ueq <4 x float> , +define <4 x i1> @test4() { + %foo = fcmp ueq <4 x float> , - ret <4 x i32> %foo + ret <4 x i1> %foo } diff --git a/utils/llvm.grm b/utils/llvm.grm index 2ca849d6797..1426e3b98e2 100644 --- a/utils/llvm.grm +++ b/utils/llvm.grm @@ -238,8 +238,6 @@ ConstExpr::= CastOps "(" ^ ConstVal to Types ^ ")" | LogicalOps "(" ^ ConstVal ^ "," ConstVal ^ ")" | icmp IPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" | fcmp FPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" - | vicmp IPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" - | vfcmp FPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" | extractelement "(" ^ ConstVal ^ "," ConstVal ^ ")" | insertelement "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" | shufflevector "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" @@ -382,8 +380,6 @@ InstVal ::= | LogicalOps Types ValueRef ^ "," ValueRef | icmp IPredicates Types ValueRef ^ "," ValueRef | fcmp FPredicates Types ValueRef ^ "," ValueRef - | vicmp IPredicates Types ValueRef ^ "," ValueRef - | vfcmp FPredicates Types ValueRef ^ "," ValueRef | CastOps ResolvedVal to Types | select ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal | "va_arg" ResolvedVal ^ "," Types