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