1 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse2 -emit-llvm -ffp-exception-behavior=strict -o - -Wall -Werror | FileCheck %s
2 
3 
4 #include <immintrin.h>
5 
test_mm_cmpeq_pd(__m128d A,__m128d B)6 __m128d test_mm_cmpeq_pd(__m128d A, __m128d B) {
7   // CHECK-LABEL: test_mm_cmpeq_pd
8   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmp.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
9   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
10   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
11   // CHECK-NEXT:    ret <2 x double> [[BC]]
12   return _mm_cmpeq_pd(A, B);
13 }
14 
test_mm_cmpge_pd(__m128d A,__m128d B)15 __m128d test_mm_cmpge_pd(__m128d A, __m128d B) {
16   // CHECK-LABEL: test_mm_cmpge_pd
17   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"ole", metadata !"fpexcept.strict")
18   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
19   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
20   // CHECK-NEXT:    ret <2 x double> [[BC]]
21   return _mm_cmpge_pd(A, B);
22 }
23 
test_mm_cmpgt_pd(__m128d A,__m128d B)24 __m128d test_mm_cmpgt_pd(__m128d A, __m128d B) {
25   // CHECK-LABEL: test_mm_cmpgt_pd
26   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
27   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
28   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
29   // CHECK-NEXT:    ret <2 x double> [[BC]]
30   return _mm_cmpgt_pd(A, B);
31 }
32 
test_mm_cmple_pd(__m128d A,__m128d B)33 __m128d test_mm_cmple_pd(__m128d A, __m128d B) {
34   // CHECK-LABEL: test_mm_cmple_pd
35   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"ole", metadata !"fpexcept.strict")
36   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
37   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
38   // CHECK-NEXT:    ret <2 x double> [[BC]]
39   return _mm_cmple_pd(A, B);
40 }
41 
test_mm_cmplt_pd(__m128d A,__m128d B)42 __m128d test_mm_cmplt_pd(__m128d A, __m128d B) {
43   // CHECK-LABEL: test_mm_cmplt_pd
44   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"olt", metadata !"fpexcept.strict")
45   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
46   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
47   // CHECK-NEXT:    ret <2 x double> [[BC]]
48   return _mm_cmplt_pd(A, B);
49 }
50 
test_mm_cmpneq_pd(__m128d A,__m128d B)51 __m128d test_mm_cmpneq_pd(__m128d A, __m128d B) {
52   // CHECK-LABEL: test_mm_cmpneq_pd
53   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmp.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"une", metadata !"fpexcept.strict")
54   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
55   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
56   // CHECK-NEXT:    ret <2 x double> [[BC]]
57   return _mm_cmpneq_pd(A, B);
58 }
59 
test_mm_cmpnge_pd(__m128d A,__m128d B)60 __m128d test_mm_cmpnge_pd(__m128d A, __m128d B) {
61   // CHECK-LABEL: test_mm_cmpnge_pd
62   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"ugt", metadata !"fpexcept.strict")
63   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
64   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
65   // CHECK-NEXT:    ret <2 x double> [[BC]]
66   return _mm_cmpnge_pd(A, B);
67 }
68 
test_mm_cmpngt_pd(__m128d A,__m128d B)69 __m128d test_mm_cmpngt_pd(__m128d A, __m128d B) {
70   // CHECK-LABEL: test_mm_cmpngt_pd
71   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
72   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
73   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
74   // CHECK-NEXT:    ret <2 x double> [[BC]]
75   return _mm_cmpngt_pd(A, B);
76 }
77 
test_mm_cmpnle_pd(__m128d A,__m128d B)78 __m128d test_mm_cmpnle_pd(__m128d A, __m128d B) {
79   // CHECK-LABEL: test_mm_cmpnle_pd
80   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"ugt", metadata !"fpexcept.strict")
81   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
82   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
83   // CHECK-NEXT:    ret <2 x double> [[BC]]
84   return _mm_cmpnle_pd(A, B);
85 }
86 
test_mm_cmpnlt_pd(__m128d A,__m128d B)87 __m128d test_mm_cmpnlt_pd(__m128d A, __m128d B) {
88   // CHECK-LABEL: test_mm_cmpnlt_pd
89   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmps.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"uge", metadata !"fpexcept.strict")
90   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
91   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
92   // CHECK-NEXT:    ret <2 x double> [[BC]]
93   return _mm_cmpnlt_pd(A, B);
94 }
95 
test_mm_cmpord_pd(__m128d A,__m128d B)96 __m128d test_mm_cmpord_pd(__m128d A, __m128d B) {
97   // CHECK-LABEL: test_mm_cmpord_pd
98   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmp.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"ord", metadata !"fpexcept.strict")
99   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
100   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
101   // CHECK-NEXT:    ret <2 x double> [[BC]]
102   return _mm_cmpord_pd(A, B);
103 }
104 
test_mm_cmpunord_pd(__m128d A,__m128d B)105 __m128d test_mm_cmpunord_pd(__m128d A, __m128d B) {
106   // CHECK-LABEL: test_mm_cmpunord_pd
107   // CHECK:         [[CMP:%.*]] = call <2 x i1> @llvm.experimental.constrained.fcmp.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"uno", metadata !"fpexcept.strict")
108   // CHECK-NEXT:    [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
109   // CHECK-NEXT:    [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
110   // CHECK-NEXT:    ret <2 x double> [[BC]]
111   return _mm_cmpunord_pd(A, B);
112 }
113