]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/R600/fp-classify.ll
Vendor import of llvm RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1):
[FreeBSD/FreeBSD.git] / test / CodeGen / R600 / fp-classify.ll
1 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
2
3 declare i1 @llvm.AMDGPU.class.f32(float, i32) #1
4 declare i1 @llvm.AMDGPU.class.f64(double, i32) #1
5 declare i32 @llvm.r600.read.tidig.x() #1
6 declare float @llvm.fabs.f32(float) #1
7 declare double @llvm.fabs.f64(double) #1
8
9 ; SI-LABEL: {{^}}test_isinf_pattern:
10 ; SI: v_mov_b32_e32 [[MASK:v[0-9]+]], 0x204{{$}}
11 ; SI: v_cmp_class_f32_e32 vcc, s{{[0-9]+}}, [[MASK]]
12 ; SI-NOT: v_cmp
13 ; SI: s_endpgm
14 define void @test_isinf_pattern(i32 addrspace(1)* nocapture %out, float %x) #0 {
15   %fabs = tail call float @llvm.fabs.f32(float %x) #1
16   %cmp = fcmp oeq float %fabs, 0x7FF0000000000000
17   %ext = zext i1 %cmp to i32
18   store i32 %ext, i32 addrspace(1)* %out, align 4
19   ret void
20 }
21
22 ; SI-LABEL: {{^}}test_not_isinf_pattern_0:
23 ; SI-NOT: v_cmp_class
24 ; SI: s_endpgm
25 define void @test_not_isinf_pattern_0(i32 addrspace(1)* nocapture %out, float %x) #0 {
26   %fabs = tail call float @llvm.fabs.f32(float %x) #1
27   %cmp = fcmp ueq float %fabs, 0x7FF0000000000000
28   %ext = zext i1 %cmp to i32
29   store i32 %ext, i32 addrspace(1)* %out, align 4
30   ret void
31 }
32
33 ; SI-LABEL: {{^}}test_not_isinf_pattern_1:
34 ; SI-NOT: v_cmp_class
35 ; SI: s_endpgm
36 define void @test_not_isinf_pattern_1(i32 addrspace(1)* nocapture %out, float %x) #0 {
37   %fabs = tail call float @llvm.fabs.f32(float %x) #1
38   %cmp = fcmp oeq float %fabs, 0xFFF0000000000000
39   %ext = zext i1 %cmp to i32
40   store i32 %ext, i32 addrspace(1)* %out, align 4
41   ret void
42 }
43
44 ; SI-LABEL: {{^}}test_isfinite_pattern_0:
45 ; SI-NOT: v_cmp
46 ; SI: v_mov_b32_e32 [[MASK:v[0-9]+]], 0x1f8{{$}}
47 ; SI: v_cmp_class_f32_e32 vcc, s{{[0-9]+}}, [[MASK]]
48 ; SI-NOT: v_cmp
49 ; SI: s_endpgm
50 define void @test_isfinite_pattern_0(i32 addrspace(1)* nocapture %out, float %x) #0 {
51   %ord = fcmp ord float %x, 0.000000e+00
52   %x.fabs = tail call float @llvm.fabs.f32(float %x) #1
53   %ninf = fcmp une float %x.fabs, 0x7FF0000000000000
54   %and = and i1 %ord, %ninf
55   %ext = zext i1 %and to i32
56   store i32 %ext, i32 addrspace(1)* %out, align 4
57   ret void
58 }
59
60 ; Use negative infinity
61 ; SI-LABEL: {{^}}test_isfinite_not_pattern_0:
62 ; SI-NOT: v_cmp_class_f32
63 ; SI: s_endpgm
64 define void @test_isfinite_not_pattern_0(i32 addrspace(1)* nocapture %out, float %x) #0 {
65   %ord = fcmp ord float %x, 0.000000e+00
66   %x.fabs = tail call float @llvm.fabs.f32(float %x) #1
67   %ninf = fcmp une float %x.fabs, 0xFFF0000000000000
68   %and = and i1 %ord, %ninf
69   %ext = zext i1 %and to i32
70   store i32 %ext, i32 addrspace(1)* %out, align 4
71   ret void
72 }
73
74 ; No fabs
75 ; SI-LABEL: {{^}}test_isfinite_not_pattern_1:
76 ; SI-NOT: v_cmp_class_f32
77 ; SI: s_endpgm
78 define void @test_isfinite_not_pattern_1(i32 addrspace(1)* nocapture %out, float %x) #0 {
79   %ord = fcmp ord float %x, 0.000000e+00
80   %ninf = fcmp une float %x, 0x7FF0000000000000
81   %and = and i1 %ord, %ninf
82   %ext = zext i1 %and to i32
83   store i32 %ext, i32 addrspace(1)* %out, align 4
84   ret void
85 }
86
87 ; fabs of different value
88 ; SI-LABEL: {{^}}test_isfinite_not_pattern_2:
89 ; SI-NOT: v_cmp_class_f32
90 ; SI: s_endpgm
91 define void @test_isfinite_not_pattern_2(i32 addrspace(1)* nocapture %out, float %x, float %y) #0 {
92   %ord = fcmp ord float %x, 0.000000e+00
93   %x.fabs = tail call float @llvm.fabs.f32(float %y) #1
94   %ninf = fcmp une float %x.fabs, 0x7FF0000000000000
95   %and = and i1 %ord, %ninf
96   %ext = zext i1 %and to i32
97   store i32 %ext, i32 addrspace(1)* %out, align 4
98   ret void
99 }
100
101 ; Wrong ordered compare type
102 ; SI-LABEL: {{^}}test_isfinite_not_pattern_3:
103 ; SI-NOT: v_cmp_class_f32
104 ; SI: s_endpgm
105 define void @test_isfinite_not_pattern_3(i32 addrspace(1)* nocapture %out, float %x) #0 {
106   %ord = fcmp uno float %x, 0.000000e+00
107   %x.fabs = tail call float @llvm.fabs.f32(float %x) #1
108   %ninf = fcmp une float %x.fabs, 0x7FF0000000000000
109   %and = and i1 %ord, %ninf
110   %ext = zext i1 %and to i32
111   store i32 %ext, i32 addrspace(1)* %out, align 4
112   ret void
113 }
114
115 ; Wrong unordered compare
116 ; SI-LABEL: {{^}}test_isfinite_not_pattern_4:
117 ; SI-NOT: v_cmp_class_f32
118 ; SI: s_endpgm
119 define void @test_isfinite_not_pattern_4(i32 addrspace(1)* nocapture %out, float %x) #0 {
120   %ord = fcmp ord float %x, 0.000000e+00
121   %x.fabs = tail call float @llvm.fabs.f32(float %x) #1
122   %ninf = fcmp one float %x.fabs, 0x7FF0000000000000
123   %and = and i1 %ord, %ninf
124   %ext = zext i1 %and to i32
125   store i32 %ext, i32 addrspace(1)* %out, align 4
126   ret void
127 }
128
129 attributes #0 = { nounwind }
130 attributes #1 = { nounwind readnone }