Skip to content

Commit 93c349b

Browse files
authored
[DAG] computeKnownFPClass - Add handling for AssertNoFPClass (llvm#190185)
Resolves llvm#189478 Adds code to handle AssertNoFPClass in computeKnownFPClass and adds IR test coverage for RISC-V.
1 parent 87dda6a commit 93c349b

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6121,6 +6121,14 @@ KnownFPClass SelectionDAG::computeKnownFPClass(SDValue Op,
61216121
Known.fabs();
61226122
break;
61236123
}
6124+
case ISD::AssertNoFPClass: {
6125+
Known = computeKnownFPClass(Op.getOperand(0), DemandedElts,
6126+
InterestedClasses, Depth + 1);
6127+
FPClassTest AssertedClasses =
6128+
static_cast<FPClassTest>(Op->getConstantOperandVal(1));
6129+
Known.KnownFPClasses &= ~AssertedClasses;
6130+
break;
6131+
}
61246132
default:
61256133
if (Opcode >= ISD::BUILTIN_OP_END || Opcode == ISD::INTRINSIC_WO_CHAIN ||
61266134
Opcode == ISD::INTRINSIC_W_CHAIN || Opcode == ISD::INTRINSIC_VOID) {
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
2+
; RUN: llc -mtriple=riscv64 -mattr=+v,+f,+d -target-abi=lp64d < %s | FileCheck %s
3+
4+
define <vscale x 4 x i1> @test_full_pinf_vs_pinf(<vscale x 4 x float> nofpclass(pinf) %a) {
5+
; CHECK-LABEL: test_full_pinf_vs_pinf:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
8+
; CHECK-NEXT: vmclr.m v0
9+
; CHECK-NEXT: ret
10+
%class = call <vscale x 4 x i1> @llvm.is.fpclass.nxv4f32(<vscale x 4 x float> %a, i32 512)
11+
ret <vscale x 4 x i1> %class
12+
}
13+
14+
define <vscale x 4 x i1> @test_full_fabs_nan_vs_nan(<vscale x 4 x float> nofpclass(nan) %a) {
15+
; CHECK-LABEL: test_full_fabs_nan_vs_nan:
16+
; CHECK: # %bb.0:
17+
; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
18+
; CHECK-NEXT: vmclr.m v0
19+
; CHECK-NEXT: ret
20+
%abs = call <vscale x 4 x float> @llvm.fabs.nxv4f32(<vscale x 4 x float> %a)
21+
%class = call <vscale x 4 x i1> @llvm.is.fpclass.nxv4f32(<vscale x 4 x float> %abs, i32 3)
22+
ret <vscale x 4 x i1> %class
23+
}
24+
25+
define <vscale x 4 x i1> @test_partial_nan_from_nan_pinf(<vscale x 4 x float> nofpclass(nan) %a) {
26+
; CHECK-LABEL: test_partial_nan_from_nan_pinf:
27+
; CHECK: # %bb.0:
28+
; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
29+
; CHECK-NEXT: vfclass.v v8, v8
30+
; CHECK-NEXT: li a0, 128
31+
; CHECK-NEXT: vmseq.vx v0, v8, a0
32+
; CHECK-NEXT: ret
33+
%class = call <vscale x 4 x i1> @llvm.is.fpclass.nxv4f32(<vscale x 4 x float> %a, i32 515)
34+
ret <vscale x 4 x i1> %class
35+
}
36+
37+
define <vscale x 4 x i1> @test_partial_pinf_from_inf(<vscale x 4 x float> nofpclass(pinf) %a) {
38+
; CHECK-LABEL: test_partial_pinf_from_inf:
39+
; CHECK: # %bb.0:
40+
; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
41+
; CHECK-NEXT: vfclass.v v8, v8
42+
; CHECK-NEXT: li a0, 64
43+
; CHECK-NEXT: vmseq.vx v0, v8, a0
44+
; CHECK-NEXT: ret
45+
%class = call <vscale x 4 x i1> @llvm.is.fpclass.nxv4f32(<vscale x 4 x float> %a, i32 768)
46+
ret <vscale x 4 x i1> %class
47+
}
48+
49+
define <vscale x 4 x i1> @test_no_overlap_pinf_vs_nan(<vscale x 4 x float> nofpclass(pinf) %a) {
50+
; CHECK-LABEL: test_no_overlap_pinf_vs_nan:
51+
; CHECK: # %bb.0:
52+
; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
53+
; CHECK-NEXT: vfclass.v v8, v8
54+
; CHECK-NEXT: li a0, 768
55+
; CHECK-NEXT: vand.vx v8, v8, a0
56+
; CHECK-NEXT: vmsne.vi v0, v8, 0
57+
; CHECK-NEXT: ret
58+
%class = call <vscale x 4 x i1> @llvm.is.fpclass.nxv4f32(<vscale x 4 x float> %a, i32 3)
59+
ret <vscale x 4 x i1> %class
60+
}
61+
62+
define <vscale x 4 x i1> @test_no_overlap_nan_vs_pinf(<vscale x 4 x float> nofpclass(nan) %a) {
63+
; CHECK-LABEL: test_no_overlap_nan_vs_pinf:
64+
; CHECK: # %bb.0:
65+
; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
66+
; CHECK-NEXT: vfclass.v v8, v8
67+
; CHECK-NEXT: li a0, 128
68+
; CHECK-NEXT: vmseq.vx v0, v8, a0
69+
; CHECK-NEXT: ret
70+
%class = call <vscale x 4 x i1> @llvm.is.fpclass.nxv4f32(<vscale x 4 x float> %a, i32 512)
71+
ret <vscale x 4 x i1> %class
72+
}

0 commit comments

Comments
 (0)