Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions llvm/lib/Target/X86/GISel/X86InstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
: X86::UCOMISDrr;
break;
case 80:
OpCmp = X86::UCOM_FpIr80;
break;
}

Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,9 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,

// fp comparison
getActionDefinitionsBuilder(G_FCMP)
.legalIf([=](const LegalityQuery &Query) {
return (HasSSE1 && typePairInSet(0, 1, {{s8, s32}})(Query)) ||
(HasSSE2 && typePairInSet(0, 1, {{s8, s64}})(Query));
})
.legalFor(HasSSE1 || UseX87, {s8, s32})
.legalFor(HasSSE2 || UseX87, {s8, s64})
.legalFor(UseX87, {s8, s80})
.clampScalar(0, s8, s8)
.clampScalar(1, s32, HasSSE2 ? s64 : s32)
.widenScalarToNextPow2(1);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/GISel/X86RegisterBankInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ X86RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {

unsigned Size = Ty1.getSizeInBits();
(void)Size;
assert((Size == 32 || Size == 64) && "Unsupported size for G_FCMP");

assert((Size == 32 || Size == 64 || Size == 80) &&
"Unsupported size for G_FCMP");
auto FpRegBank = getPartialMappingIdx(MI, Ty1, /* isFP= */ true);
OpRegBankIdx = {PMI_GPR8,
/* Predicate */ PMI_None, FpRegBank, FpRegBank};
Expand Down
Loading