builtin_float.c
2.54 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
// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-pc -o - %s | FileCheck %s --check-prefixes=CHECK,FP16
// RUN: %clang_cc1 -emit-llvm -triple ppc64-be -o - %s -DNO_FP16 | FileCheck %s --check-prefixes=CHECK,NOFP16
// test to ensure that these builtins don't do the variadic promotion of float->double.
void test_floats(float f1, float f2) {
(void)__builtin_isgreater(f1, f2);
// CHECK: fcmp ogt float
// CHECK-NEXT: zext i1
(void)__builtin_isgreaterequal(f1, f2);
// CHECK: fcmp oge float
// CHECK-NEXT: zext i1
(void)__builtin_isless(f1, f2);
// CHECK: fcmp olt float
// CHECK-NEXT: zext i1
(void)__builtin_islessequal(f1, f2);
// CHECK: fcmp ole float
// CHECK-NEXT: zext i1
(void)__builtin_islessgreater(f1, f2);
// CHECK: fcmp one float
// CHECK-NEXT: zext i1
(void)__builtin_isunordered(f1, f2);
// CHECK: fcmp uno float
// CHECK-NEXT: zext i1
}
void test_doubles(double d1, double f2) {
(void)__builtin_isgreater(d1, f2);
// CHECK: fcmp ogt double
// CHECK-NEXT: zext i1
(void)__builtin_isgreaterequal(d1, f2);
// CHECK: fcmp oge double
// CHECK-NEXT: zext i1
(void)__builtin_isless(d1, f2);
// CHECK: fcmp olt double
// CHECK-NEXT: zext i1
(void)__builtin_islessequal(d1, f2);
// CHECK: fcmp ole double
// CHECK-NEXT: zext i1
(void)__builtin_islessgreater(d1, f2);
// CHECK: fcmp one double
// CHECK-NEXT: zext i1
(void)__builtin_isunordered(d1, f2);
// CHECK: fcmp uno double
// CHECK-NEXT: zext i1
}
void test_half(__fp16 *H, __fp16 *H2) {
(void)__builtin_isgreater(*H, *H2);
// CHECK: fcmp ogt float
// CHECK-NEXT: zext i1
(void)__builtin_isinf(*H);
// NOFP16: fcmp oeq float %{{.+}}, 0x7FF
// FP16: fcmp oeq half %{{.+}}, 0xH7C
}
void test_mixed(double d1, float f2) {
(void)__builtin_isgreater(d1, f2);
// CHECK: fpext float {{.*}} to double
// CHECK-NEXT: fcmp ogt double
// CHECK-NEXT: zext i1
(void)__builtin_isgreaterequal(d1, f2);
// CHECK: fpext float {{.*}} to double
// CHECK-NEXT: fcmp oge double
// CHECK-NEXT: zext i1
(void)__builtin_isless(d1, f2);
// CHECK: fpext float {{.*}} to double
// CHECK-NEXT: fcmp olt double
// CHECK-NEXT: zext i1
(void)__builtin_islessequal(d1, f2);
// CHECK: fpext float {{.*}} to double
// CHECK-NEXT: fcmp ole double
// CHECK-NEXT: zext i1
(void)__builtin_islessgreater(d1, f2);
// CHECK: fpext float {{.*}} to double
// CHECK-NEXT: fcmp one double
// CHECK-NEXT: zext i1
(void)__builtin_isunordered(d1, f2);
// CHECK: fpext float {{.*}} to double
// CHECK-NEXT: fcmp uno double
// CHECK-NEXT: zext i1
}