Page MenuHomePhabricator

[MIPS GlobalISel] Select fcmp
ClosedPublic

Authored by Petar.Avramovic on May 31 2019, 1:50 AM.

Details

Summary

Select floating point compare for MIPS32.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan accepted this revision.Jun 3 2019, 2:15 AM

LGTM wit a nit.

lib/Target/Mips/MipsInstructionSelector.cpp
497 ↗(On Diff #202391)

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;
This revision is now accepted and ready to land.Jun 3 2019, 2:15 AM

Addressed review comments.

This revision was automatically updated to reflect the committed changes.