tdc-05.ll
2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
; Test the Test Data Class instruction logic operation conversion from
; compares, combined with signbit or other compares to ensure worthiness.
;
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
;
declare float @llvm.fabs.f32(float)
declare double @llvm.fabs.f64(double)
declare fp128 @llvm.fabs.f128(fp128)
; Compare with 0, extract sign bit
define i32 @f1(float %x) {
; CHECK-LABEL: f1
; CHECK: tceb %f0, 2047
%cast = bitcast float %x to i32
%sign = icmp slt i32 %cast, 0
%fcmp = fcmp ugt float %x, 0.0
%res = or i1 %sign, %fcmp
%xres = zext i1 %res to i32
ret i32 %xres
}
; Compare with inf, extract negated sign bit
define i32 @f2(float %x) {
; CHECK-LABEL: f2
; CHECK: tceb %f0, 2698
%cast = bitcast float %x to i32
%sign = icmp sgt i32 %cast, -1
%fcmp = fcmp ult float %x, 0x7ff0000000000000
%res = and i1 %sign, %fcmp
%xres = zext i1 %res to i32
ret i32 %xres
}
; Compare with minnorm, extract negated sign bit
define i32 @f3(float %x) {
; CHECK-LABEL: f3
; CHECK: tceb %f0, 2176
%cast = bitcast float %x to i32
%sign = icmp sgt i32 %cast, -1
%fcmp = fcmp olt float %x, 0x3810000000000000
%res = and i1 %sign, %fcmp
%xres = zext i1 %res to i32
ret i32 %xres
}
; Test float isnormal, from clang.
define i32 @f4(float %x) {
; CHECK-LABEL: f4
; CHECK: tceb %f0, 768
%y = call float @llvm.fabs.f32(float %x)
%ord = fcmp ord float %x, 0.0
%a = fcmp ult float %y, 0x7ff0000000000000
%b = fcmp uge float %y, 0x3810000000000000
%c = and i1 %a, %b
%res = and i1 %ord, %c
%xres = zext i1 %res to i32
ret i32 %xres
}
; Check for negative 0.
define i32 @f5(float %x) {
; CHECK-LABEL: f5
; CHECK: tceb %f0, 1024
%cast = bitcast float %x to i32
%sign = icmp slt i32 %cast, 0
%fcmp = fcmp oeq float %x, 0.0
%res = and i1 %sign, %fcmp
%xres = zext i1 %res to i32
ret i32 %xres
}
; Test isnormal, from clang.
define i32 @f6(double %x) {
; CHECK-LABEL: f6
; CHECK: tcdb %f0, 768
%y = call double @llvm.fabs.f64(double %x)
%ord = fcmp ord double %x, 0.0
%a = fcmp ult double %y, 0x7ff0000000000000
%b = fcmp uge double %y, 0x0010000000000000
%c = and i1 %ord, %a
%res = and i1 %b, %c
%xres = zext i1 %res to i32
ret i32 %xres
}
; Test isinf || isnan, from clang.
define i32 @f7(double %x) {
; CHECK-LABEL: f7
; CHECK: tcdb %f0, 63
%y = call double @llvm.fabs.f64(double %x)
%a = fcmp oeq double %y, 0x7ff0000000000000
%b = fcmp uno double %x, 0.0
%res = or i1 %a, %b
%xres = zext i1 %res to i32
ret i32 %xres
}