Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / X86 / sse-builtins-constrained-cmp.c
blobeb1488885e5dd03bebfc806a97e109d5d6e8a5ed
1 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -emit-llvm -ffp-exception-behavior=strict -o - -Wall -Werror | FileCheck %s
4 #include <immintrin.h>
6 __m128 test_mm_cmpeq_ps(__m128 __a, __m128 __b) {
7 // CHECK-LABEL: test_mm_cmpeq_ps
8 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
9 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
10 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
11 // CHECK-NEXT: ret <4 x float> [[BC]]
12 return _mm_cmpeq_ps(__a, __b);
15 __m128 test_mm_cmpge_ps(__m128 __a, __m128 __b) {
16 // CHECK-LABEL: test_mm_cmpge_ps
17 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ole", metadata !"fpexcept.strict")
18 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
19 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
20 // CHECK-NEXT: ret <4 x float> [[BC]]
21 return _mm_cmpge_ps(__a, __b);
24 __m128 test_mm_cmpgt_ps(__m128 __a, __m128 __b) {
25 // CHECK-LABEL: test_mm_cmpgt_ps
26 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
27 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
28 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
29 // CHECK-NEXT: ret <4 x float> [[BC]]
30 return _mm_cmpgt_ps(__a, __b);
33 __m128 test_mm_cmple_ps(__m128 __a, __m128 __b) {
34 // CHECK-LABEL: test_mm_cmple_ps
35 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ole", metadata !"fpexcept.strict")
36 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
37 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
38 // CHECK-NEXT: ret <4 x float> [[BC]]
39 return _mm_cmple_ps(__a, __b);
42 __m128 test_mm_cmplt_ps(__m128 __a, __m128 __b) {
43 // CHECK-LABEL: test_mm_cmplt_ps
44 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
45 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
46 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
47 // CHECK-NEXT: ret <4 x float> [[BC]]
48 return _mm_cmplt_ps(__a, __b);
51 __m128 test_mm_cmpneq_ps(__m128 __a, __m128 __b) {
52 // CHECK-LABEL: test_mm_cmpneq_ps
53 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"une", metadata !"fpexcept.strict")
54 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
55 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
56 // CHECK-NEXT: ret <4 x float> [[BC]]
57 return _mm_cmpneq_ps(__a, __b);
60 __m128 test_mm_cmpnge_ps(__m128 __a, __m128 __b) {
61 // CHECK-LABEL: test_mm_cmpnge_ps
62 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ugt", metadata !"fpexcept.strict")
63 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
64 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
65 // CHECK-NEXT: ret <4 x float> [[BC]]
66 return _mm_cmpnge_ps(__a, __b);
69 __m128 test_mm_cmpngt_ps(__m128 __a, __m128 __b) {
70 // CHECK-LABEL: test_mm_cmpngt_ps
71 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
72 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
73 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
74 // CHECK-NEXT: ret <4 x float> [[BC]]
75 return _mm_cmpngt_ps(__a, __b);
78 __m128 test_mm_cmpnle_ps(__m128 __a, __m128 __b) {
79 // CHECK-LABEL: test_mm_cmpnle_ps
80 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ugt", metadata !"fpexcept.strict")
81 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
82 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
83 // CHECK-NEXT: ret <4 x float> [[BC]]
84 return _mm_cmpnle_ps(__a, __b);
87 __m128 test_mm_cmpnlt_ps(__m128 __a, __m128 __b) {
88 // CHECK-LABEL: test_mm_cmpnlt_ps
89 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmps.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
90 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
91 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
92 // CHECK-NEXT: ret <4 x float> [[BC]]
93 return _mm_cmpnlt_ps(__a, __b);
96 __m128 test_mm_cmpord_ps(__m128 __a, __m128 __b) {
97 // CHECK-LABEL: test_mm_cmpord_ps
98 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"ord", metadata !"fpexcept.strict")
99 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
100 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
101 // CHECK-NEXT: ret <4 x float> [[BC]]
102 return _mm_cmpord_ps(__a, __b);
105 __m128 test_mm_cmpunord_ps(__m128 __a, __m128 __b) {
106 // CHECK-LABEL: test_mm_cmpunord_ps
107 // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.experimental.constrained.fcmp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"uno", metadata !"fpexcept.strict")
108 // CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
109 // CHECK-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
110 // CHECK-NEXT: ret <4 x float> [[BC]]
111 return _mm_cmpunord_ps(__a, __b);