[PATCH] D62721: [MIPS GlobalISel] Select fcmp
Simon Atanasyan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 02:16:24 PDT 2019
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.
LGTM wit a nit.
================
Comment at: lib/Target/Mips/MipsInstructionSelector.cpp:497
+ case G_FCMP: {
+ struct {
+ unsigned MipsFCMPCondCode, MoveOpcode;
----------------
I think we do not need to introduce a structure just to initialize a couple of values. But it's up to you.
```
unsigned MipsFCMPCondCode;
switch (static_cast<CmpInst::Predicate>(I.getOperand(1).getPredicate())) {
case CmpInst::FCMP_UNO: // Unordered
case CmpInst::FCMP_ORD: // Ordered (OR)
MipsFCMPCondCode = Mips::FCOND_UN;
isLogicallyNegated = Cond != CmpInst::FCMP_UNO;
break;
case CmpInst::FCMP_OEQ: // Equal
case CmpInst::FCMP_UNE: // Not Equal (NEQ)
MipsFCMPCondCode = Mips::FCOND_OEQ;
isLogicallyNegated = Cond != CmpInst::FCMP_OEQ;
break;
case CmpInst::FCMP_UEQ: // Unordered or Equal
case CmpInst::FCMP_ONE: // Ordered or Greater Than or Less Than (OGL)
MipsFCMPCondCode = Mips::FCOND_UEQ;
isLogicallyNegated = Cond != CmpInst::FCMP_UEQ;
break;
case CmpInst::FCMP_OLT: // Ordered or Less Than
case CmpInst::FCMP_UGE: // Unordered or Greater Than or Equal (UGE)
MipsFCMPCondCode = Mips::FCOND_OLT;
isLogicallyNegated = Cond != CmpInst::FCMP_OLT;
break;
case CmpInst::FCMP_ULT: // Unordered or Less Than
case CmpInst::FCMP_OGE: // Ordered or Greater Than or Equal (OGE)
MipsFCMPCondCode = Mips::FCOND_ULT;
isLogicallyNegated = Cond != CmpInst::FCMP_ULT;
break;
case CmpInst::FCMP_OLE: // Ordered or Less Than or Equal
case CmpInst::FCMP_UGT: // Unordered or Greater Than (UGT)
MipsFCMPCondCode = Mips::FCOND_OLE;
isLogicallyNegated = Cond != CmpInst::FCMP_OLE;
break;
case CmpInst::FCMP_ULE: // Unordered or Less Than or Equal
case CmpInst::FCMP_OGT: // Ordered or Greater Than (OGT)
MipsFCMPCondCode = Mips::FCOND_ULE;
isLogicallyNegated = Cond != CmpInst::FCMP_ULE;
break;
default:
return false;
}
// Default compare result in gpr register will be `true`.
// We will move `false` (MIPS::Zero) to gpr result when fcmp gives false
// using MOVF_I. When orignal predicate (Cond) is logically negated FCC,
// result is invertet i.e. MOVT_I is used.
unsigned MoveOpcode = isLogicallyNegated ? Mips::MOVT_I : Mips::MOVF_I;
```
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62721/new/
https://reviews.llvm.org/D62721
More information about the llvm-commits
mailing list