[llvm] [RISCV] Simplify float-point boundary comparisons with FCLASS (PR #228984)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 23:38:30 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Julian Zhu (HeliC829)
<details>
<summary>Changes</summary>
Simplify float-point boundary comparisons with FCLASS instruction.
---
Patch is 26.37 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/228984.diff
4 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+57)
- (added) llvm/test/CodeGen/RISCV/fcmp-boundary-fclass.ll (+690)
- (modified) llvm/test/CodeGen/RISCV/rv64-float-convert.ll (+6-7)
- (modified) llvm/test/CodeGen/RISCV/rv64-half-convert.ll (+6-7)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 4b9175b9aad274c..5789248f66b2080 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -20852,6 +20852,59 @@ combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, ISD::CondCode CC,
DAG.getConstant(0, DL, XLenVT), CC);
}
+static SDValue combineFPBoundarySetCC(SDNode *N, SelectionDAG &DAG,
+ const RISCVSubtarget &Subtarget) {
+ SDValue X = N->getOperand(0);
+ SDValue Bound = N->getOperand(1);
+ EVT FPVT = X.getValueType();
+ if ((FPVT != MVT::f32 && FPVT != MVT::f64) ||
+ (FPVT == MVT::f32 && !Subtarget.hasStdExtFOrZfinx()) ||
+ (FPVT == MVT::f64 && !Subtarget.hasStdExtDOrZdinx()) ||
+ !isa<ConstantFPSDNode>(Bound))
+ return SDValue();
+
+ const APFloat &C = cast<ConstantFPSDNode>(Bound)->getValueAPF();
+ ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(2))->get();
+ FPClassTest Mask = fcNone;
+ FPClassTest NaNs = fcSNan | fcQNan;
+ if (C.bitwiseIsEqual(APFloat::getLargest(C.getSemantics(), true))) {
+ if (CC == ISD::SETOLT || CC == ISD::SETULT)
+ Mask = fcNegInf;
+ else if (CC == ISD::SETOGE || CC == ISD::SETUGE)
+ Mask = fcAllFlags & ~(fcNegInf | NaNs);
+ } else if (C.bitwiseIsEqual(APFloat::getLargest(C.getSemantics()))) {
+ if (CC == ISD::SETOGT || CC == ISD::SETUGT)
+ Mask = fcPosInf;
+ else if (CC == ISD::SETOLE || CC == ISD::SETULE)
+ Mask = fcAllFlags & ~(fcPosInf | NaNs);
+ } else if (!Subtarget.hasStdExtZfa() && FPVT == MVT::f64 &&
+ DAG.getDenormalMode(FPVT).Input == DenormalMode::IEEE) {
+ // Without FLI.D, materializing this bound costs more than FCLASS.D.
+ FPClassTest Below = fcNegInf | fcNegNormal | fcNegSubnormal | fcNegZero |
+ fcPosZero | fcPosSubnormal;
+ if (C.bitwiseIsEqual(APFloat::getSmallestNormalized(C.getSemantics()))) {
+ if (CC == ISD::SETOLT || CC == ISD::SETULT)
+ Mask = Below;
+ else if (CC == ISD::SETOGE || CC == ISD::SETUGE)
+ Mask = fcPosNormal | fcPosInf;
+ } else if (C.bitwiseIsEqual(
+ APFloat::getSmallestNormalized(C.getSemantics(), true))) {
+ if (CC == ISD::SETOGT || CC == ISD::SETUGT)
+ Mask = fcAllFlags & ~(fcNegInf | fcNegNormal | NaNs);
+ else if (CC == ISD::SETOLE || CC == ISD::SETULE)
+ Mask = fcNegInf | fcNegNormal;
+ }
+ }
+ if (Mask == fcNone)
+ return SDValue();
+ if (CC == ISD::SETULT || CC == ISD::SETUGE || CC == ISD::SETUGT ||
+ CC == ISD::SETULE)
+ Mask |= NaNs;
+ SDLoc DL(N);
+ return DAG.getNode(ISD::IS_FPCLASS, DL, N->getValueType(0), X,
+ DAG.getTargetConstant(Mask, DL, MVT::i32));
+}
+
static SDValue performSETCCCombine(SDNode *N,
TargetLowering::DAGCombinerInfo &DCI,
const RISCVSubtarget &Subtarget) {
@@ -20862,6 +20915,10 @@ static SDValue performSETCCCombine(SDNode *N,
EVT VT = N->getValueType(0);
EVT OpVT = N0.getValueType();
+ if (DCI.isBeforeLegalizeOps() && OpVT.isFloatingPoint())
+ if (SDValue V = combineFPBoundarySetCC(N, DAG, Subtarget))
+ return V;
+
ISD::CondCode Cond = cast<CondCodeSDNode>(N->getOperand(2))->get();
if (SDValue V =
canonicalizeMaskForVLPredicate(VT, N0, N1, Cond, dl, DAG, DCI))
diff --git a/llvm/test/CodeGen/RISCV/fcmp-boundary-fclass.ll b/llvm/test/CodeGen/RISCV/fcmp-boundary-fclass.ll
new file mode 100644
index 000000000000000..ee3673a47310394
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/fcmp-boundary-fclass.ll
@@ -0,0 +1,690 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=riscv64 -mattr=+d -verify-machineinstrs < %s \
+; RUN: | FileCheck %s --check-prefix=RV64D
+; RUN: llc -mtriple=riscv64 -mattr=+d,+zfa -verify-machineinstrs < %s \
+; RUN: | FileCheck %s --check-prefix=RV64ZFA
+; RUN: llc -mtriple=riscv32 -mattr=+d -verify-machineinstrs < %s \
+; RUN: | FileCheck %s --check-prefix=RV32D
+; RUN: llc -mtriple=riscv64 -mattr=+zdinx -verify-machineinstrs < %s \
+; RUN: | FileCheck %s --check-prefix=RV64ZDINX
+
+define i1 @below_negative_max_float(float %x) {
+; RV64D-LABEL: below_negative_max_float:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.s a0, fa0
+; RV64D-NEXT: andi a0, a0, 1
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: below_negative_max_float:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.s a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 1
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: below_negative_max_float:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.s a0, fa0
+; RV32D-NEXT: andi a0, a0, 1
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: below_negative_max_float:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.s a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 1
+; RV64ZDINX-NEXT: ret
+ %r = fcmp olt float %x, 0xC7EFFFFFE0000000
+ ret i1 %r
+}
+
+define i1 @above_positive_max_float(float %x) {
+; RV64D-LABEL: above_positive_max_float:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.s a0, fa0
+; RV64D-NEXT: slli a0, a0, 56
+; RV64D-NEXT: srli a0, a0, 63
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: above_positive_max_float:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.s a0, fa0
+; RV64ZFA-NEXT: slli a0, a0, 56
+; RV64ZFA-NEXT: srli a0, a0, 63
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: above_positive_max_float:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.s a0, fa0
+; RV32D-NEXT: slli a0, a0, 24
+; RV32D-NEXT: srli a0, a0, 31
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: above_positive_max_float:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.s a0, a0
+; RV64ZDINX-NEXT: slli a0, a0, 56
+; RV64ZDINX-NEXT: srli a0, a0, 63
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ogt float %x, 0x47EFFFFFE0000000
+ ret i1 %r
+}
+
+define i1 @at_least_negative_max_float_unordered(float %x) {
+; RV64D-LABEL: at_least_negative_max_float_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.s a0, fa0
+; RV64D-NEXT: andi a0, a0, 1022
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_least_negative_max_float_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.s a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 1022
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_least_negative_max_float_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.s a0, fa0
+; RV32D-NEXT: andi a0, a0, 1022
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_least_negative_max_float_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.s a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 1022
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp uge float %x, 0xC7EFFFFFE0000000
+ ret i1 %r
+}
+
+define i1 @below_negative_max(double %x) {
+; RV64D-LABEL: below_negative_max:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 1
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: below_negative_max:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 1
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: below_negative_max:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 1
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: below_negative_max:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 1
+; RV64ZDINX-NEXT: ret
+ %r = fcmp olt double %x, 0xFFEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @above_positive_max(double %x) {
+; RV64D-LABEL: above_positive_max:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: slli a0, a0, 56
+; RV64D-NEXT: srli a0, a0, 63
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: above_positive_max:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: slli a0, a0, 56
+; RV64ZFA-NEXT: srli a0, a0, 63
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: above_positive_max:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: slli a0, a0, 24
+; RV32D-NEXT: srli a0, a0, 31
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: above_positive_max:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: slli a0, a0, 56
+; RV64ZDINX-NEXT: srli a0, a0, 63
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ogt double %x, 0x7FEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @below_negative_max_unordered(double %x) {
+; RV64D-LABEL: below_negative_max_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 769
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: below_negative_max_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 769
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: below_negative_max_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 769
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: below_negative_max_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 769
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ult double %x, 0xFFEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @at_most_positive_max(double %x) {
+; RV64D-LABEL: at_most_positive_max:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 127
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_most_positive_max:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 127
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_most_positive_max:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 127
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_most_positive_max:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 127
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ole double %x, 0x7FEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @at_least_negative_max(double %x) {
+; RV64D-LABEL: at_least_negative_max:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 254
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_least_negative_max:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 254
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_least_negative_max:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 254
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_least_negative_max:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 254
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp oge double %x, 0xFFEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @at_least_negative_max_unordered(double %x) {
+; RV64D-LABEL: at_least_negative_max_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 1022
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_least_negative_max_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 1022
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_least_negative_max_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 1022
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_least_negative_max_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 1022
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp uge double %x, 0xFFEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @above_positive_max_unordered(double %x) {
+; RV64D-LABEL: above_positive_max_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 896
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: above_positive_max_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 896
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: above_positive_max_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 896
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: above_positive_max_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 896
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ugt double %x, 0x7FEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @at_most_positive_max_unordered(double %x) {
+; RV64D-LABEL: at_most_positive_max_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 895
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_most_positive_max_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fclass.d a0, fa0
+; RV64ZFA-NEXT: andi a0, a0, 895
+; RV64ZFA-NEXT: snez a0, a0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_most_positive_max_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 895
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_most_positive_max_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 895
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ule double %x, 0x7FEFFFFFFFFFFFFF
+ ret i1 %r
+}
+
+define i1 @below_min_normal(double %x) {
+; RV64D-LABEL: below_min_normal:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 63
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: below_min_normal:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: flt.d a0, fa0, fa5
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: below_min_normal:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 63
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: below_min_normal:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 63
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp olt double %x, 0x0010000000000000
+ ret i1 %r
+}
+
+define i1 @at_least_min_normal(double %x) {
+; RV64D-LABEL: at_least_min_normal:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 192
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_least_min_normal:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: fle.d a0, fa5, fa0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_least_min_normal:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 192
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_least_min_normal:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 192
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp oge double %x, 0x0010000000000000
+ ret i1 %r
+}
+
+define i1 @above_negative_min_normal(double %x) {
+; RV64D-LABEL: above_negative_min_normal:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 252
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: above_negative_min_normal:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: fneg.d fa5, fa5
+; RV64ZFA-NEXT: flt.d a0, fa5, fa0
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: above_negative_min_normal:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 252
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: above_negative_min_normal:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 252
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ogt double %x, 0x8010000000000000
+ ret i1 %r
+}
+
+define i1 @at_most_negative_min_normal(double %x) {
+; RV64D-LABEL: at_most_negative_min_normal:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 3
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_most_negative_min_normal:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: fneg.d fa5, fa5
+; RV64ZFA-NEXT: fle.d a0, fa0, fa5
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_most_negative_min_normal:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 3
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_most_negative_min_normal:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 3
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ole double %x, 0x8010000000000000
+ ret i1 %r
+}
+
+define i1 @below_min_normal_unordered(double %x) {
+; RV64D-LABEL: below_min_normal_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 831
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: below_min_normal_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: fle.d a0, fa5, fa0
+; RV64ZFA-NEXT: xori a0, a0, 1
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: below_min_normal_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 831
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: below_min_normal_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 831
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp ult double %x, 0x0010000000000000
+ ret i1 %r
+}
+
+define i1 @at_least_min_normal_unordered(double %x) {
+; RV64D-LABEL: at_least_min_normal_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 960
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: at_least_min_normal_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: flt.d a0, fa0, fa5
+; RV64ZFA-NEXT: xori a0, a0, 1
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: at_least_min_normal_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 960
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: at_least_min_normal_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV64ZDINX-NEXT: andi a0, a0, 960
+; RV64ZDINX-NEXT: snez a0, a0
+; RV64ZDINX-NEXT: ret
+ %r = fcmp uge double %x, 0x0010000000000000
+ ret i1 %r
+}
+
+define i1 @above_negative_min_normal_unordered(double %x) {
+; RV64D-LABEL: above_negative_min_normal_unordered:
+; RV64D: # %bb.0:
+; RV64D-NEXT: fclass.d a0, fa0
+; RV64D-NEXT: andi a0, a0, 1020
+; RV64D-NEXT: snez a0, a0
+; RV64D-NEXT: ret
+;
+; RV64ZFA-LABEL: above_negative_min_normal_unordered:
+; RV64ZFA: # %bb.0:
+; RV64ZFA-NEXT: fli.d fa5, min
+; RV64ZFA-NEXT: fneg.d fa5, fa5
+; RV64ZFA-NEXT: fle.d a0, fa0, fa5
+; RV64ZFA-NEXT: xori a0, a0, 1
+; RV64ZFA-NEXT: ret
+;
+; RV32D-LABEL: above_negative_min_normal_unordered:
+; RV32D: # %bb.0:
+; RV32D-NEXT: fclass.d a0, fa0
+; RV32D-NEXT: andi a0, a0, 1020
+; RV32D-NEXT: snez a0, a0
+; RV32D-NEXT: ret
+;
+; RV64ZDINX-LABEL: above_negative_min_normal_unordered:
+; RV64ZDINX: # %bb.0:
+; RV64ZDINX-NEXT: fclass.d a0, a0
+; RV6...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/228984
More information about the llvm-commits
mailing list