[llvm] [X86][GlobalISel] Support G_FCMP for scalar cases (PR #123598)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 13:11:47 PST 2025
================
@@ -1048,17 +1048,29 @@ bool X86InstructionSelector::selectFCmp(MachineInstr &I,
break;
}
+ assert((LhsReg.isVirtual() && RhsReg.isVirtual()) &&
+ "Both arguments of FCMP need to be virtual!");
+ auto *LhsBank = RBI.getRegBank(LhsReg, MRI, TRI);
+ auto *RhsBank = RBI.getRegBank(RhsReg, MRI, TRI);
+ assert((LhsBank == RhsBank) &&
+ "Both banks assigned to FCMP arguments need to be same!");
+
// Compute the opcode for the CMP instruction.
unsigned OpCmp;
LLT Ty = MRI.getType(LhsReg);
switch (Ty.getSizeInBits()) {
default:
return false;
case 32:
- OpCmp = X86::UCOMISSrr;
+ OpCmp = LhsBank->getID() == X86::PSRRegBankID ? X86::UCOM_FpIr32
+ : X86::UCOMISSrr;
break;
case 64:
- OpCmp = X86::UCOMISDrr;
+ OpCmp = LhsBank->getID() == X86::PSRRegBankID ? X86::UCOM_FpIr64
----------------
e-kud wrote:
floats and doubles are supported as well but haven't been covered with tests. Let's take IR from `test/CodeGen/X86/GlobalISel/select-fcmp.mir` and create `llvm/test/CodeGen/X86/isel-fcmp.ll`. We can test it for `x86-64` where `SSE` is present and `i686` where `x87` must be used. They should be supported already.
https://github.com/llvm/llvm-project/pull/123598
More information about the llvm-commits
mailing list