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
This commit is contained in:
Nick Lewycky 2009-07-08 03:04:38 +00:00
parent 34a0fa362d
commit 7f6aa2b162
31 changed files with 99 additions and 664 deletions

View File

@ -155,8 +155,6 @@
<ol>
<li><a href="#i_icmp">'<tt>icmp</tt>' Instruction</a></li>
<li><a href="#i_fcmp">'<tt>fcmp</tt>' Instruction</a></li>
<li><a href="#i_vicmp">'<tt>vicmp</tt>' Instruction</a></li>
<li><a href="#i_vfcmp">'<tt>vfcmp</tt>' Instruction</a></li>
<li><a href="#i_phi">'<tt>phi</tt>' Instruction</a></li>
<li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
<li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
@ -2042,12 +2040,6 @@ following is the syntax for constant expressions:</p>
<dt><b><tt>fcmp COND ( VAL1, VAL2 )</tt></b></dt>
<dd>Performs the <a href="#i_fcmp">fcmp operation</a> on constants.</dd>
<dt><b><tt>vicmp COND ( VAL1, VAL2 )</tt></b></dt>
<dd>Performs the <a href="#i_vicmp">vicmp operation</a> on constants.</dd>
<dt><b><tt>vfcmp COND ( VAL1, VAL2 )</tt></b></dt>
<dd>Performs the <a href="#i_vfcmp">vfcmp operation</a> on constants.</dd>
<dt><b><tt>extractelement ( VAL, IDX )</tt></b></dt>
<dd>Perform the <a href="#i_extractelement">extractelement
@ -4504,109 +4496,6 @@ always yields an <a href="#t_primitive">i1</a> result, as follows:</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vicmp">'<tt>vicmp</tt>' Instruction</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre> &lt;result&gt; = vicmp &lt;cond&gt; &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt; <i>; yields {ty}:result</i>
</pre>
<h5>Overview:</h5>
<p>The '<tt>vicmp</tt>' instruction returns an integer vector value based on
element-wise comparison of its two integer vector operands.</p>
<h5>Arguments:</h5>
<p>The '<tt>vicmp</tt>' 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:</p>
<ol>
<li><tt>eq</tt>: equal</li>
<li><tt>ne</tt>: not equal </li>
<li><tt>ugt</tt>: unsigned greater than</li>
<li><tt>uge</tt>: unsigned greater or equal</li>
<li><tt>ult</tt>: unsigned less than</li>
<li><tt>ule</tt>: unsigned less or equal</li>
<li><tt>sgt</tt>: signed greater than</li>
<li><tt>sge</tt>: signed greater or equal</li>
<li><tt>slt</tt>: signed less than</li>
<li><tt>sle</tt>: signed less or equal</li>
</ol>
<p>The remaining two arguments must be <a href="#t_vector">vector</a> or
<a href="#t_integer">integer</a> typed. They must also be identical types.</p>
<h5>Semantics:</h5>
<p>The '<tt>vicmp</tt>' instruction compares <tt>op1</tt> and <tt>op2</tt>
according to the condition code given as <tt>cond</tt>. The comparison yields a
<a href="#t_vector">vector</a> of <a href="#t_integer">integer</a> 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 <a href="#i_icmp">'<tt>icmp</tt>'
instruction</a>.</p>
<h5>Example:</h5>
<pre>
&lt;result&gt; = vicmp eq &lt;2 x i32&gt; &lt; i32 4, i32 0&gt;, &lt; i32 5, i32 0&gt; <i>; yields: result=&lt;2 x i32&gt; &lt; i32 0, i32 -1 &gt;</i>
&lt;result&gt; = vicmp ult &lt;2 x i8 &gt; &lt; i8 1, i8 2&gt;, &lt; i8 2, i8 2 &gt; <i>; yields: result=&lt;2 x i8&gt; &lt; i8 -1, i8 0 &gt;</i>
</pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_vfcmp">'<tt>vfcmp</tt>' Instruction</a>
</div>
<div class="doc_text">
<h5>Syntax:</h5>
<pre> &lt;result&gt; = vfcmp &lt;cond&gt; &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;</pre>
<h5>Overview:</h5>
<p>The '<tt>vfcmp</tt>' 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.</p>
<h5>Arguments:</h5>
<p>The '<tt>vfcmp</tt>' 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:</p>
<ol>
<li><tt>false</tt>: no comparison, always returns false</li>
<li><tt>oeq</tt>: ordered and equal</li>
<li><tt>ogt</tt>: ordered and greater than </li>
<li><tt>oge</tt>: ordered and greater than or equal</li>
<li><tt>olt</tt>: ordered and less than </li>
<li><tt>ole</tt>: ordered and less than or equal</li>
<li><tt>one</tt>: ordered and not equal</li>
<li><tt>ord</tt>: ordered (no nans)</li>
<li><tt>ueq</tt>: unordered or equal</li>
<li><tt>ugt</tt>: unordered or greater than </li>
<li><tt>uge</tt>: unordered or greater than or equal</li>
<li><tt>ult</tt>: unordered or less than </li>
<li><tt>ule</tt>: unordered or less than or equal</li>
<li><tt>une</tt>: unordered or not equal</li>
<li><tt>uno</tt>: unordered (either nans)</li>
<li><tt>true</tt>: no comparison, always returns true</li>
</ol>
<p>The remaining two arguments must be <a href="#t_vector">vector</a> of
<a href="#t_floating">floating point</a> typed. They must also be identical
types.</p>
<h5>Semantics:</h5>
<p>The '<tt>vfcmp</tt>' instruction compares <tt>op1</tt> and <tt>op2</tt>
according to the condition code given as <tt>cond</tt>. The comparison yields a
<a href="#t_vector">vector</a> of <a href="#t_integer">integer</a> 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
<a href="#i_fcmp">'<tt>fcmp</tt>' instruction</a>.</p>
<h5>Example:</h5>
<pre>
<i>; yields: result=&lt;2 x i32&gt; &lt; i32 0, i32 -1 &gt;</i>
&lt;result&gt; = vfcmp oeq &lt;2 x float&gt; &lt; float 4, float 0 &gt;, &lt; float 5, float 0 &gt;
<i>; yields: result=&lt;2 x i64&gt; &lt; i64 -1, i64 0 &gt;</i>
&lt;result&gt; = vfcmp ult &lt;2 x double&gt; &lt; double 1, double 2 &gt;, &lt; double 2, double 2&gt;
</pre>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
<a name="i_phi">'<tt>phi</tt>' Instruction</a>

View File

@ -341,8 +341,6 @@ void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle);
macro(CmpInst) \
macro(FCmpInst) \
macro(ICmpInst) \
macro(VFCmpInst) \
macro(VICmpInst) \
macro(ExtractElementInst) \
macro(GetElementPtrInst) \
macro(InsertElementInst) \

View File

@ -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]

View File

@ -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);

View File

@ -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<Instruction>(V) && classof(cast<Instruction>(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<const VectorType>(opnd_type)) {
return VectorType::get(Type::Int1Ty, vt->getNumElements());

View File

@ -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

View File

@ -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<Instruction>(V) && classof(cast<Instruction>(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<VectorType>(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<VectorType>(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<Instruction>(V) && classof(cast<Instruction>(V));
}
};
//===----------------------------------------------------------------------===//
// CallInst Class
//===----------------------------------------------------------------------===//

View File

@ -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);

View File

@ -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

View File

@ -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<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(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<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateVFCmp(P, LC, RC);
return Insert(new VFCmpInst(P, LHS, RHS), Name);
}
//===--------------------------------------------------------------------===//
// Instruction creation methods: Other Instructions
//===--------------------------------------------------------------------===//

View File

@ -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); }

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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,

View File

@ -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,9 +1628,13 @@ 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
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
unsigned OpNum = 0;
Value *LHS, *RHS;
if (getValueTypePair(Record, OpNum, NextValueNo, LHS) ||
@ -1642,31 +1642,13 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
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_CMP2: { // CMP2: [opty, opval, opval, pred]
// 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");
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");

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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,

View File

@ -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);

View File

@ -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";

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 1, i32 2, i32 1, i32 2> ) ;
global <4 x i1> icmp slt ( <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 1, i32 2, i32 1, i32 2> ) ;
@B = external global i32;
global <4 x i32> vicmp slt ( <4 x i32> <i32 ptrtoint (i32 * @B to i32), i32 1, i32 1, i32 1>, <4 x i32> <i32 1, i32 2, i32 1, i32 2> ) ;
global <4 x i1> icmp slt ( <4 x i32> <i32 ptrtoint (i32 * @B to i32), i32 1, i32 1, i32 1>, <4 x i32> <i32 1, i32 2, i32 1, i32 2> ) ;

View File

@ -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, <i32 14, i32 undef, i32 undef, i32 undef>
ret <4 x i32> %foo
%foo = icmp slt <4 x i32> undef, <i32 14, i32 undef, i32 undef, 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> <i32 undef, i32 undef, i32 undef, i32
%foo = icmp slt <4 x i32> <i32 undef, i32 undef, i32 undef, i32
undef>, <i32 undef, i32 undef, i32 undef, i32 undef>
ret <4 x i32> %foo
ret <4 x i1> %foo
}
define <4 x i32> @test3() {
%foo = vfcmp ueq <4 x float> <float 0.0, float 0.0, float 0.0, float
define <4 x i1> @test3() {
%foo = fcmp ueq <4 x float> <float 0.0, float 0.0, float 0.0, float
undef>, <float 1.0, float 1.0, float 1.0, float undef>
ret <4 x i32> %foo
ret <4 x i1> %foo
}
define <4 x i32> @test4() {
%foo = vfcmp ueq <4 x float> <float 0.0, float 0.0, float 0.0, float 0.0>, <float 1.0, float 1.0, float 1.0, float 0.0>
define <4 x i1> @test4() {
%foo = fcmp ueq <4 x float> <float 0.0, float 0.0, float 0.0, float 0.0>, <float 1.0, float 1.0, float 1.0, float 0.0>
ret <4 x i32> %foo
ret <4 x i1> %foo
}

View File

@ -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