[llvm] acd6cb8 - [RISCV][GISel] Support fcmp and fclass for Zfh. (#96696)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 09:53:15 PDT 2024
Author: Craig Topper
Date: 2024-06-26T09:53:13-07:00
New Revision: acd6cb85b3c410e88dbcc9e48733d0e1ac70eadc
URL: https://github.com/llvm/llvm-project/commit/acd6cb85b3c410e88dbcc9e48733d0e1ac70eadc
DIFF: https://github.com/llvm/llvm-project/commit/acd6cb85b3c410e88dbcc9e48733d0e1ac70eadc.diff
LOG: [RISCV][GISel] Support fcmp and fclass for Zfh. (#96696)
Added:
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv64.mir
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv64.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv64.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv64.mir
llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv64.mir
llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv64.mir
Modified:
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
index 53b2c7e196899..f511a20109803 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
@@ -1148,16 +1148,16 @@ bool RISCVInstructionSelector::selectSelect(MachineInstr &MI,
// Convert an FCMP predicate to one of the supported F or D instructions.
static unsigned getFCmpOpcode(CmpInst::Predicate Pred, unsigned Size) {
- assert((Size == 32 || Size == 64) && "Unsupported size");
+ assert((Size == 16 || Size == 32 || Size == 64) && "Unsupported size");
switch (Pred) {
default:
llvm_unreachable("Unsupported predicate");
case CmpInst::FCMP_OLT:
- return Size == 32 ? RISCV::FLT_S : RISCV::FLT_D;
+ return Size == 16 ? RISCV::FLT_H : Size == 32 ? RISCV::FLT_S : RISCV::FLT_D;
case CmpInst::FCMP_OLE:
- return Size == 32 ? RISCV::FLE_S : RISCV::FLE_D;
+ return Size == 16 ? RISCV::FLE_H : Size == 32 ? RISCV::FLE_S : RISCV::FLE_D;
case CmpInst::FCMP_OEQ:
- return Size == 32 ? RISCV::FEQ_S : RISCV::FEQ_D;
+ return Size == 16 ? RISCV::FEQ_H : Size == 32 ? RISCV::FEQ_S : RISCV::FEQ_D;
}
}
@@ -1209,7 +1209,7 @@ bool RISCVInstructionSelector::selectFPCompare(MachineInstr &MI,
Register RHS = CmpMI.getRHSReg();
unsigned Size = MRI.getType(LHS).getSizeInBits();
- assert((Size == 32 || Size == 64) && "Unexpected size");
+ assert((Size == 16 || Size == 32 || Size == 64) && "Unexpected size");
Register TmpReg = DstReg;
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index 122b742c52ee9..f6761ce5c105e 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -402,13 +402,20 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
typeIs(1, s32)(Query));
});
- getActionDefinitionsBuilder(G_FCMP)
- .legalIf(all(typeIs(0, sXLen), typeIsScalarFPArith(1, ST)))
- .clampScalar(0, sXLen, sXLen);
+ auto &FCmpActions = getActionDefinitionsBuilder(G_FCMP).legalIf(
+ all(typeIs(0, sXLen), typeIsScalarFPArith(1, ST)));
+ // TODO: Fold this into typeIsScalarFPArith.
+ if (ST.hasStdExtZfh())
+ FCmpActions.legalFor({sXLen, s16});
+ FCmpActions.clampScalar(0, sXLen, sXLen);
// TODO: Support vector version of G_IS_FPCLASS.
- getActionDefinitionsBuilder(G_IS_FPCLASS)
- .customIf(all(typeIs(0, s1), typeIsScalarFPArith(1, ST)));
+ auto &FClassActions =
+ getActionDefinitionsBuilder(G_IS_FPCLASS)
+ .customIf(all(typeIs(0, s1), typeIsScalarFPArith(1, ST)));
+ // TODO: Fold this into typeIsScalarFPArith.
+ if (ST.hasStdExtZfh())
+ FClassActions.customFor({s1, s16});
auto &FConstantActions = getActionDefinitionsBuilder(G_FCONSTANT)
.legalIf(typeIsScalarFPArith(0, ST));
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
index 41ca164b38f3d..d25e96525399e 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
@@ -478,7 +478,6 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
LLT Ty = MRI.getType(MI.getOperand(2).getReg());
unsigned Size = Ty.getSizeInBits();
- assert((Size == 32 || Size == 64) && "Unsupported size for G_FCMP");
OpdsMapping[0] = GPRValueMapping;
OpdsMapping[2] = OpdsMapping[3] = getFPValueMapping(Size);
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv32.mir
new file mode 100644
index 0000000000000..6fdfd65a15f00
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv32.mir
@@ -0,0 +1,355 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv32 -mattr=+zfh -run-pass=instruction-select \
+# RUN: -simplify-mir -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: fcmp_oeq_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oeq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = nofpexcept FEQ_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FEQ_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(oeq), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ogt_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ogt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: $x10 = COPY [[FLT_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ogt), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_oge_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = FLE_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: $x10 = COPY [[FLE_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(oge), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_olt_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_olt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = nofpexcept FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FLT_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(olt), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ole_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ole_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = nofpexcept FLE_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FLE_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ole), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_one_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_one_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[FLT_H1:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[OR:%[0-9]+]]:gpr = OR [[FLT_H]], [[FLT_H1]]
+ ; CHECK-NEXT: $x10 = COPY [[OR]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(one), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ord_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ord_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = FEQ_H [[COPY]], [[COPY]]
+ ; CHECK-NEXT: [[FEQ_H1:%[0-9]+]]:gpr = FEQ_H [[COPY1]], [[COPY1]]
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:gpr = AND [[FEQ_H]], [[FEQ_H1]]
+ ; CHECK-NEXT: $x10 = COPY [[AND]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ord), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ueq_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ueq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[FLT_H1:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[OR:%[0-9]+]]:gpr = OR [[FLT_H]], [[FLT_H1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[OR]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ueq), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ugt_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ugt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = FLE_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLE_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ugt), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uge_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLT_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(uge), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ult_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ult_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = FLE_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLE_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ult), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ule_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ule_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLT_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(ule), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_une_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_une_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = FEQ_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FEQ_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(une), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uno_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uno_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = FEQ_H [[COPY]], [[COPY]]
+ ; CHECK-NEXT: [[FEQ_H1:%[0-9]+]]:gpr = FEQ_H [[COPY1]], [[COPY1]]
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:gpr = AND [[FEQ_H]], [[FEQ_H1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[AND]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s32) = G_FCMP floatpred(uno), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv64.mir
new file mode 100644
index 0000000000000..827d3e567e6f1
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/fcmp-f16-rv64.mir
@@ -0,0 +1,355 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv64 -mattr=+zfh -run-pass=instruction-select \
+# RUN: -simplify-mir -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: fcmp_oeq_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oeq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = nofpexcept FEQ_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FEQ_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(oeq), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ogt_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ogt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: $x10 = COPY [[FLT_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ogt), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_oge_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = FLE_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: $x10 = COPY [[FLE_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(oge), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_olt_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_olt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = nofpexcept FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FLT_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(olt), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ole_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ole_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = nofpexcept FLE_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FLE_H]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ole), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_one_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_one_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[FLT_H1:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[OR:%[0-9]+]]:gpr = OR [[FLT_H]], [[FLT_H1]]
+ ; CHECK-NEXT: $x10 = COPY [[OR]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(one), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ord_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ord_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = FEQ_H [[COPY]], [[COPY]]
+ ; CHECK-NEXT: [[FEQ_H1:%[0-9]+]]:gpr = FEQ_H [[COPY1]], [[COPY1]]
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:gpr = AND [[FEQ_H]], [[FEQ_H1]]
+ ; CHECK-NEXT: $x10 = COPY [[AND]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ord), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ueq_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ueq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[FLT_H1:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[OR:%[0-9]+]]:gpr = OR [[FLT_H]], [[FLT_H1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[OR]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ueq), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ugt_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ugt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = FLE_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLE_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ugt), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uge_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLT_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(uge), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ult_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ult_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLE_H:%[0-9]+]]:gpr = FLE_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLE_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ult), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ule_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ule_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FLT_H:%[0-9]+]]:gpr = FLT_H [[COPY1]], [[COPY]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FLT_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(ule), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_une_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_une_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = FEQ_H [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[FEQ_H]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(une), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uno_f16
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uno_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr16 = COPY $f11_h
+ ; CHECK-NEXT: [[FEQ_H:%[0-9]+]]:gpr = FEQ_H [[COPY]], [[COPY]]
+ ; CHECK-NEXT: [[FEQ_H1:%[0-9]+]]:gpr = FEQ_H [[COPY1]], [[COPY1]]
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:gpr = AND [[FEQ_H]], [[FEQ_H1]]
+ ; CHECK-NEXT: [[XORI:%[0-9]+]]:gpr = XORI [[AND]], 1
+ ; CHECK-NEXT: $x10 = COPY [[XORI]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %1:fprb(s16) = COPY $f11_h
+ %4:gprb(s64) = G_FCMP floatpred(uno), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv32.mir
new file mode 100644
index 0000000000000..b8ff04a7e6bec
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv32.mir
@@ -0,0 +1,82 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
+# RUN: llc -mtriple=riscv32 -mattr=+zfh -run-pass=instruction-select -verify-machineinstrs %s -o - | \
+# RUN: FileCheck %s
+
+---
+name: is_fpclass_f16
+legalized: true
+regBankSelected: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[FCLASS_H:%[0-9]+]]:gpr = FCLASS_H [[COPY]]
+ ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_H]], 152
+ ; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
+ ; CHECK-NEXT: $x10 = COPY [[SLTU]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %3:gprb(s32) = G_CONSTANT i32 152
+ %4:gprb(s32) = G_CONSTANT i32 0
+ %5:gprb(s32) = G_FCLASS %0(s16)
+ %6:gprb(s32) = G_AND %5, %3
+ %7:gprb(s32) = G_ICMP intpred(ne), %6(s32), %4
+ $x10 = COPY %7(s32)
+ PseudoRET implicit $x10
+...
+---
+name: is_fpclass_f16_onehot
+legalized: true
+regBankSelected: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16_onehot
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[FCLASS_H:%[0-9]+]]:gpr = FCLASS_H [[COPY]]
+ ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_H]], 256
+ ; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
+ ; CHECK-NEXT: $x10 = COPY [[SLTU]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %3:gprb(s32) = G_CONSTANT i32 256
+ %4:gprb(s32) = G_CONSTANT i32 0
+ %5:gprb(s32) = G_FCLASS %0(s16)
+ %6:gprb(s32) = G_AND %5, %3
+ %7:gprb(s32) = G_ICMP intpred(ne), %6(s32), %4
+ $x10 = COPY %7(s32)
+ PseudoRET implicit $x10
+...
+---
+name: is_fpclass_f16_one
+legalized: true
+regBankSelected: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16_one
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[FCLASS_H:%[0-9]+]]:gpr = FCLASS_H [[COPY]]
+ ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_H]], 1
+ ; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
+ ; CHECK-NEXT: $x10 = COPY [[SLTU]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %3:gprb(s32) = G_CONSTANT i32 1
+ %4:gprb(s32) = G_CONSTANT i32 0
+ %5:gprb(s32) = G_FCLASS %0(s16)
+ %6:gprb(s32) = G_AND %5, %3
+ %7:gprb(s32) = G_ICMP intpred(ne), %6(s32), %4
+ $x10 = COPY %7(s32)
+ PseudoRET implicit $x10
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv64.mir
new file mode 100644
index 0000000000000..3860657ea8f03
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/is-fpclass-f16-rv64.mir
@@ -0,0 +1,82 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
+# RUN: llc -mtriple=riscv64 -mattr=+zfh -run-pass=instruction-select -verify-machineinstrs %s -o - | \
+# RUN: FileCheck %s
+
+---
+name: is_fpclass_f16
+legalized: true
+regBankSelected: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[FCLASS_H:%[0-9]+]]:gpr = FCLASS_H [[COPY]]
+ ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_H]], 152
+ ; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
+ ; CHECK-NEXT: $x10 = COPY [[SLTU]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %3:gprb(s64) = G_CONSTANT i64 152
+ %4:gprb(s64) = G_CONSTANT i64 0
+ %5:gprb(s64) = G_FCLASS %0(s16)
+ %6:gprb(s64) = G_AND %5, %3
+ %7:gprb(s64) = G_ICMP intpred(ne), %6(s64), %4
+ $x10 = COPY %7(s64)
+ PseudoRET implicit $x10
+...
+---
+name: is_fpclass_f16_onehot
+legalized: true
+regBankSelected: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16_onehot
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[FCLASS_H:%[0-9]+]]:gpr = FCLASS_H [[COPY]]
+ ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_H]], 256
+ ; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
+ ; CHECK-NEXT: $x10 = COPY [[SLTU]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %3:gprb(s64) = G_CONSTANT i64 256
+ %4:gprb(s64) = G_CONSTANT i64 0
+ %5:gprb(s64) = G_FCLASS %0(s16)
+ %6:gprb(s64) = G_AND %5, %3
+ %7:gprb(s64) = G_ICMP intpred(ne), %6(s64), %4
+ $x10 = COPY %7(s64)
+ PseudoRET implicit $x10
+...
+---
+name: is_fpclass_f16_one
+legalized: true
+regBankSelected: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16_one
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr16 = COPY $f10_h
+ ; CHECK-NEXT: [[FCLASS_H:%[0-9]+]]:gpr = FCLASS_H [[COPY]]
+ ; CHECK-NEXT: [[ANDI:%[0-9]+]]:gpr = ANDI [[FCLASS_H]], 1
+ ; CHECK-NEXT: [[SLTU:%[0-9]+]]:gpr = SLTU $x0, [[ANDI]]
+ ; CHECK-NEXT: $x10 = COPY [[SLTU]]
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:fprb(s16) = COPY $f10_h
+ %3:gprb(s64) = G_CONSTANT i64 1
+ %4:gprb(s64) = G_CONSTANT i64 0
+ %5:gprb(s64) = G_FCLASS %0(s16)
+ %6:gprb(s64) = G_AND %5, %3
+ %7:gprb(s64) = G_ICMP intpred(ne), %6(s64), %4
+ $x10 = COPY %7(s64)
+ PseudoRET implicit $x10
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv32.mir
new file mode 100644
index 0000000000000..6aaaf50d386ba
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv32.mir
@@ -0,0 +1,312 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv32 -mattr=+zfh -run-pass=legalizer %s -o - \
+# RUN: | FileCheck %s
+
+---
+name: fcmp_oeq_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oeq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(oeq), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(oeq), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ogt_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ogt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ogt), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ogt), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_oge_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(oge), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(oge), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_olt_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_olt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(olt), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(olt), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ole_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ole_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ole), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ole), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_one_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_one_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(one), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(one), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ord_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ord_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ord), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ord), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ueq_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ueq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ueq), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ueq), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ugt_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ugt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ugt), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ugt), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uge_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(uge), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(uge), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ult_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ult_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ult), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ult), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ule_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ule_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(ule), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ule), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_une_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_une_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(une), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(une), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uno_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uno_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s32) = G_FCMP floatpred(uno), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(uno), %0(s16), %1
+ %3:_(s32) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s32)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv64.mir
new file mode 100644
index 0000000000000..0f604cad45512
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-fcmp-f16-rv64.mir
@@ -0,0 +1,312 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv64 -mattr=+zfh -run-pass=legalizer %s -o - \
+# RUN: | FileCheck %s
+
+---
+name: fcmp_oeq_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oeq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(oeq), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(oeq), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ogt_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ogt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ogt), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ogt), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_oge_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_oge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(oge), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(oge), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_olt_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_olt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(olt), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(olt), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ole_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ole_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ole), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ole), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_one_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_one_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(one), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(one), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ord_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ord_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ord), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ord), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ueq_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ueq_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ueq), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ueq), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ugt_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ugt_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ugt), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ugt), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uge_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uge_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(uge), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(uge), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ult_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ult_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ult), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ult), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_ule_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_ule_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(ule), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(ule), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_une_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_une_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(une), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(une), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
+---
+name: fcmp_uno_f16
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_uno_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s64) = G_FCMP floatpred(uno), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %2:_(s1) = G_FCMP floatpred(uno), %0(s16), %1
+ %3:_(s64) = G_ANYEXT %2(s1)
+ $x10 = COPY %3(s64)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv32.mir
new file mode 100644
index 0000000000000..1cbbaf09bd1ce
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv32.mir
@@ -0,0 +1,28 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
+# RUN: llc -mtriple=riscv32 -mattr=+zfh -run-pass=legalizer %s -o - \
+# RUN: | FileCheck %s
+
+---
+name: is_fpclass_f16
+body: |
+ bb.1:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 152
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
+ ; CHECK-NEXT: [[FCLASS:%[0-9]+]]:_(s32) = G_FCLASS [[COPY]](s16)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[FCLASS]], [[C]]
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ne), [[AND]](s32), [[C1]]
+ ; CHECK-NEXT: $x10 = COPY [[ICMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s1) = G_IS_FPCLASS %0(s16), 608
+ %2:_(s32) = G_ANYEXT %1(s1)
+ $x10 = COPY %2(s32)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv64.mir
new file mode 100644
index 0000000000000..ad02f5bacb820
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-is-fpclass-f16-rv64.mir
@@ -0,0 +1,28 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
+# RUN: llc -mtriple=riscv64 -mattr=+zfh -run-pass=legalizer %s -o - \
+# RUN: | FileCheck %s
+
+---
+name: is_fpclass_f16
+body: |
+ bb.1:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 152
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
+ ; CHECK-NEXT: [[FCLASS:%[0-9]+]]:_(s64) = G_FCLASS [[COPY]](s16)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[FCLASS]], [[C]]
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ne), [[AND]](s64), [[C1]]
+ ; CHECK-NEXT: $x10 = COPY [[ICMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s1) = G_IS_FPCLASS %0(s16), 608
+ %2:_(s64) = G_ANYEXT %1(s1)
+ $x10 = COPY %2(s64)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv32.mir
new file mode 100644
index 0000000000000..2a3f8bdc4d3e0
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv32.mir
@@ -0,0 +1,27 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv32 -mattr=+zfh -run-pass=regbankselect \
+# RUN: -simplify-mir -verify-machineinstrs %s \
+# RUN: -o - | FileCheck %s
+
+---
+name: fcmp_f16
+legalized: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fprb(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fprb(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:gprb(s32) = G_FCMP floatpred(oeq), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %4:_(s32) = G_FCMP floatpred(oeq), %0(s16), %1
+ $x10 = COPY %4(s32)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv64.mir
new file mode 100644
index 0000000000000..518ef4488aa44
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/fcmp-f16-rv64.mir
@@ -0,0 +1,27 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv64 -mattr=+zfh -run-pass=regbankselect \
+# RUN: -simplify-mir -verify-machineinstrs %s \
+# RUN: -o - | FileCheck %s
+
+---
+name: fcmp_f16
+legalized: true
+body: |
+ bb.1:
+ liveins: $f10_h, $f11_h
+
+ ; CHECK-LABEL: name: fcmp_f16
+ ; CHECK: liveins: $f10_h, $f11_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fprb(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fprb(s16) = COPY $f11_h
+ ; CHECK-NEXT: [[FCMP:%[0-9]+]]:gprb(s64) = G_FCMP floatpred(oeq), [[COPY]](s16), [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[FCMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %1:_(s16) = COPY $f11_h
+ %4:_(s64) = G_FCMP floatpred(oeq), %0(s16), %1
+ $x10 = COPY %4(s64)
+ PseudoRET implicit $x10
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv32.mir
new file mode 100644
index 0000000000000..9224579d6bd78
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv32.mir
@@ -0,0 +1,31 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
+# RUN: llc -mtriple=riscv32 -mattr=+zfh -run-pass=regbankselect -verify-machineinstrs %s -o - \
+# RUN: | FileCheck %s
+
+---
+name: is_fpclass_f16
+legalized: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fprb(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[C:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 152
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:gprb(s32) = G_CONSTANT i32 0
+ ; CHECK-NEXT: [[FCLASS:%[0-9]+]]:gprb(s32) = G_FCLASS [[COPY]](s16)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:gprb(s32) = G_AND [[FCLASS]], [[C]]
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:gprb(s32) = G_ICMP intpred(ne), [[AND]](s32), [[C1]]
+ ; CHECK-NEXT: $x10 = COPY [[ICMP]](s32)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %3:_(s32) = G_CONSTANT i32 152
+ %4:_(s32) = G_CONSTANT i32 0
+ %5:_(s32) = G_FCLASS %0(s16)
+ %6:_(s32) = G_AND %5, %3
+ %7:_(s32) = G_ICMP intpred(ne), %6(s32), %4
+ $x10 = COPY %7(s32)
+ PseudoRET implicit $x10
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv64.mir
new file mode 100644
index 0000000000000..9bf796d1f55e9
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/regbankselect/is-fpclass-f16-rv64.mir
@@ -0,0 +1,31 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
+# RUN: llc -mtriple=riscv64 -mattr=+zfh -run-pass=regbankselect -verify-machineinstrs %s -o - \
+# RUN: | FileCheck %s
+
+---
+name: is_fpclass_f16
+legalized: true
+body: |
+ bb.0:
+ liveins: $f10_h
+
+ ; CHECK-LABEL: name: is_fpclass_f16
+ ; CHECK: liveins: $f10_h
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:fprb(s16) = COPY $f10_h
+ ; CHECK-NEXT: [[C:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 152
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:gprb(s64) = G_CONSTANT i64 0
+ ; CHECK-NEXT: [[FCLASS:%[0-9]+]]:gprb(s64) = G_FCLASS [[COPY]](s16)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:gprb(s64) = G_AND [[FCLASS]], [[C]]
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:gprb(s64) = G_ICMP intpred(ne), [[AND]](s64), [[C1]]
+ ; CHECK-NEXT: $x10 = COPY [[ICMP]](s64)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(s16) = COPY $f10_h
+ %3:_(s64) = G_CONSTANT i64 152
+ %4:_(s64) = G_CONSTANT i64 0
+ %5:_(s64) = G_FCLASS %0(s16)
+ %6:_(s64) = G_AND %5, %3
+ %7:_(s64) = G_ICMP intpred(ne), %6(s64), %4
+ $x10 = COPY %7(s64)
+ PseudoRET implicit $x10
+...
More information about the llvm-commits
mailing list