mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[FastISel] Move optimizeCmpPredicate to FastISel base class. NFC.
Make the optimizeCmpPredicate function available to all targets. llvm-svn: 217822
This commit is contained in:
parent
03071c7bb3
commit
0a4f4becc3
@ -484,6 +484,8 @@ protected:
|
||||
/// \brief Create a machine mem operand from the given instruction.
|
||||
MachineMemOperand *createMachineMemOperandFor(const Instruction *I) const;
|
||||
|
||||
CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) const;
|
||||
|
||||
bool lowerCallTo(const CallInst *CI, const char *SymName, unsigned NumArgs);
|
||||
bool lowerCallTo(CallLoweringInfo &CLI);
|
||||
|
||||
|
@ -2142,3 +2142,43 @@ FastISel::createMachineMemOperandFor(const Instruction *I) const {
|
||||
return FuncInfo.MF->getMachineMemOperand(MachinePointerInfo(Ptr), Flags, Size,
|
||||
Alignment, AAInfo, Ranges);
|
||||
}
|
||||
|
||||
CmpInst::Predicate FastISel::optimizeCmpPredicate(const CmpInst *CI) const {
|
||||
// If both operands are the same, then try to optimize or fold the cmp.
|
||||
CmpInst::Predicate Predicate = CI->getPredicate();
|
||||
if (CI->getOperand(0) != CI->getOperand(1))
|
||||
return Predicate;
|
||||
|
||||
switch (Predicate) {
|
||||
default: llvm_unreachable("Invalid predicate!");
|
||||
case CmpInst::FCMP_FALSE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OEQ: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OGE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OLE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_ONE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_ORD: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_UNO: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UEQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UGT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_ULT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UNE: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_TRUE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
|
||||
case CmpInst::ICMP_EQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_NE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_ULT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SLE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
}
|
||||
|
||||
return Predicate;
|
||||
}
|
@ -164,46 +164,6 @@ private:
|
||||
|
||||
} // end anonymous namespace.
|
||||
|
||||
static CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) {
|
||||
// If both operands are the same, then try to optimize or fold the cmp.
|
||||
CmpInst::Predicate Predicate = CI->getPredicate();
|
||||
if (CI->getOperand(0) != CI->getOperand(1))
|
||||
return Predicate;
|
||||
|
||||
switch (Predicate) {
|
||||
default: llvm_unreachable("Invalid predicate!");
|
||||
case CmpInst::FCMP_FALSE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OEQ: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OGE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OLE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_ONE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_ORD: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_UNO: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UEQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UGT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_ULT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UNE: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_TRUE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
|
||||
case CmpInst::ICMP_EQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_NE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_ULT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SLE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
}
|
||||
|
||||
return Predicate;
|
||||
}
|
||||
|
||||
static std::pair<X86::CondCode, bool>
|
||||
getX86ConditionCode(CmpInst::Predicate Predicate) {
|
||||
X86::CondCode CC = X86::COND_INVALID;
|
||||
|
Loading…
Reference in New Issue
Block a user