Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / isfpclass.c
blob34873c08e04f87e9a95b624969ef7e78bab8141c
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
2 // RUN: %clang_cc1 -triple aarch64-linux-gnu -S -O1 -emit-llvm %s -o - | FileCheck %s
4 // CHECK-LABEL: define dso_local i1 @check_isfpclass_finite
5 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
6 // CHECK-NEXT: entry:
7 // CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.fabs.f32(float [[X]])
8 // CHECK-NEXT: [[TMP1:%.*]] = fcmp one float [[TMP0]], 0x7FF0000000000000
9 // CHECK-NEXT: ret i1 [[TMP1]]
11 _Bool check_isfpclass_finite(float x) {
12 return __builtin_isfpclass(x, 504 /*Finite*/);
15 // CHECK-LABEL: define dso_local i1 @check_isfpclass_finite_strict
16 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
17 // CHECK-NEXT: entry:
18 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 504) #[[ATTR6:[0-9]+]]
19 // CHECK-NEXT: ret i1 [[TMP0]]
21 _Bool check_isfpclass_finite_strict(float x) {
22 #pragma STDC FENV_ACCESS ON
23 return __builtin_isfpclass(x, 504 /*Finite*/);
26 // CHECK-LABEL: define dso_local i1 @check_isfpclass_nan_f32
27 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
28 // CHECK-NEXT: entry:
29 // CHECK-NEXT: [[TMP0:%.*]] = fcmp uno float [[X]], 0.000000e+00
30 // CHECK-NEXT: ret i1 [[TMP0]]
32 _Bool check_isfpclass_nan_f32(float x) {
33 return __builtin_isfpclass(x, 3 /*NaN*/);
36 // CHECK-LABEL: define dso_local i1 @check_isfpclass_nan_f32_strict
37 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
38 // CHECK-NEXT: entry:
39 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 3) #[[ATTR6]]
40 // CHECK-NEXT: ret i1 [[TMP0]]
42 _Bool check_isfpclass_nan_f32_strict(float x) {
43 #pragma STDC FENV_ACCESS ON
44 return __builtin_isfpclass(x, 3 /*NaN*/);
47 // CHECK-LABEL: define dso_local i1 @check_isfpclass_snan_f64
48 // CHECK-SAME: (double noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
49 // CHECK-NEXT: entry:
50 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f64(double [[X]], i32 1)
51 // CHECK-NEXT: ret i1 [[TMP0]]
53 _Bool check_isfpclass_snan_f64(double x) {
54 return __builtin_isfpclass(x, 1 /*SNaN*/);
57 // CHECK-LABEL: define dso_local i1 @check_isfpclass_snan_f64_strict
58 // CHECK-SAME: (double noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
59 // CHECK-NEXT: entry:
60 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f64(double [[X]], i32 1) #[[ATTR6]]
61 // CHECK-NEXT: ret i1 [[TMP0]]
63 _Bool check_isfpclass_snan_f64_strict(double x) {
64 #pragma STDC FENV_ACCESS ON
65 return __builtin_isfpclass(x, 1 /*NaN*/);
68 // CHECK-LABEL: define dso_local i1 @check_isfpclass_zero_f16
69 // CHECK-SAME: (half noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3]] {
70 // CHECK-NEXT: entry:
71 // CHECK-NEXT: [[TMP0:%.*]] = fcmp oeq half [[X]], 0xH0000
72 // CHECK-NEXT: ret i1 [[TMP0]]
74 _Bool check_isfpclass_zero_f16(_Float16 x) {
75 return __builtin_isfpclass(x, 96 /*Zero*/);
78 // CHECK-LABEL: define dso_local i1 @check_isfpclass_zero_f16_strict
79 // CHECK-SAME: (half noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
80 // CHECK-NEXT: entry:
81 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f16(half [[X]], i32 96) #[[ATTR6]]
82 // CHECK-NEXT: ret i1 [[TMP0]]
84 _Bool check_isfpclass_zero_f16_strict(_Float16 x) {
85 #pragma STDC FENV_ACCESS ON
86 return __builtin_isfpclass(x, 96 /*Zero*/);
89 // CHECK-LABEL: define dso_local i1 @check_isnan
90 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
91 // CHECK-NEXT: entry:
92 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 3) #[[ATTR6]]
93 // CHECK-NEXT: ret i1 [[TMP0]]
95 _Bool check_isnan(float x) {
96 #pragma STDC FENV_ACCESS ON
97 return __builtin_isnan(x);
100 // CHECK-LABEL: define dso_local i1 @check_isinf
101 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
102 // CHECK-NEXT: entry:
103 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 516) #[[ATTR6]]
104 // CHECK-NEXT: ret i1 [[TMP0]]
106 _Bool check_isinf(float x) {
107 #pragma STDC FENV_ACCESS ON
108 return __builtin_isinf(x);
111 // CHECK-LABEL: define dso_local i1 @check_isfinite
112 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
113 // CHECK-NEXT: entry:
114 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 504) #[[ATTR6]]
115 // CHECK-NEXT: ret i1 [[TMP0]]
117 _Bool check_isfinite(float x) {
118 #pragma STDC FENV_ACCESS ON
119 return __builtin_isfinite(x);
122 // CHECK-LABEL: define dso_local i1 @check_isnormal
123 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
124 // CHECK-NEXT: entry:
125 // CHECK-NEXT: [[TMP0:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[X]], i32 264) #[[ATTR6]]
126 // CHECK-NEXT: ret i1 [[TMP0]]
128 _Bool check_isnormal(float x) {
129 #pragma STDC FENV_ACCESS ON
130 return __builtin_isnormal(x);
134 typedef float __attribute__((ext_vector_type(4))) float4;
135 typedef double __attribute__((ext_vector_type(4))) double4;
136 typedef int __attribute__((ext_vector_type(4))) int4;
137 typedef long __attribute__((ext_vector_type(4))) long4;
139 // CHECK-LABEL: define dso_local <4 x i32> @check_isfpclass_nan_v4f32
140 // CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3]] {
141 // CHECK-NEXT: entry:
142 // CHECK-NEXT: [[TMP0:%.*]] = fcmp uno <4 x float> [[X]], zeroinitializer
143 // CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i1> [[TMP0]] to <4 x i32>
144 // CHECK-NEXT: ret <4 x i32> [[TMP1]]
146 int4 check_isfpclass_nan_v4f32(float4 x) {
147 return __builtin_isfpclass(x, 3 /*NaN*/);
150 // CHECK-LABEL: define dso_local <4 x i32> @check_isfpclass_nan_strict_v4f32
151 // CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
152 // CHECK-NEXT: entry:
153 // CHECK-NEXT: [[TMP0:%.*]] = tail call <4 x i1> @llvm.is.fpclass.v4f32(<4 x float> [[X]], i32 3) #[[ATTR6]]
154 // CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i1> [[TMP0]] to <4 x i32>
155 // CHECK-NEXT: ret <4 x i32> [[TMP1]]
157 int4 check_isfpclass_nan_strict_v4f32(float4 x) {
158 #pragma STDC FENV_ACCESS ON
159 return __builtin_isfpclass(x, 3 /*NaN*/);
162 // CHECK-LABEL: define dso_local void @check_isfpclass_nan_v4f64
163 // CHECK-SAME: (ptr noalias nocapture writeonly sret(<4 x i64>) align 16 [[AGG_RESULT:%.*]], ptr nocapture noundef readonly [[TMP0:%.*]]) local_unnamed_addr #[[ATTR4:[0-9]+]] {
164 // CHECK-NEXT: entry:
165 // CHECK-NEXT: [[X:%.*]] = load <4 x double>, ptr [[TMP0]], align 16, !tbaa [[TBAA2:![0-9]+]]
166 // CHECK-NEXT: [[TMP1:%.*]] = fcmp uno <4 x double> [[X]], zeroinitializer
167 // CHECK-NEXT: [[TMP2:%.*]] = zext <4 x i1> [[TMP1]] to <4 x i64>
168 // CHECK-NEXT: store <4 x i64> [[TMP2]], ptr [[AGG_RESULT]], align 16, !tbaa [[TBAA2]]
169 // CHECK-NEXT: ret void
171 long4 check_isfpclass_nan_v4f64(double4 x) {
172 return __builtin_isfpclass(x, 3 /*NaN*/);