X86 intrinsics: cmpge|gt|nge|ngt_ss|_sd
These intrinsics should return the comparision result in the low bits and keep
the high bits of the first source operand.
When calling to builtin functions, the source operands are swapped and the high
bits of the second source operand are kept. To fix the issue, an extra
shufflevector is used.
rdar://14153896
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184110 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/avx-cmp-builtins.c b/test/CodeGen/avx-cmp-builtins.c
index 1ac1c31..5b205d7 100644
--- a/test/CodeGen/avx-cmp-builtins.c
+++ b/test/CodeGen/avx-cmp-builtins.c
@@ -44,3 +44,51 @@
// CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 13)
return _mm_cmp_ss(a, b, _CMP_GE_OS);
}
+
+__m128 test_cmpgt_ss(__m128 a, __m128 b) {
+ // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 1)
+ // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
+ return _mm_cmpgt_ss(a, b);
+}
+
+__m128 test_cmpge_ss(__m128 a, __m128 b) {
+ // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 2)
+ // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
+ return _mm_cmpge_ss(a, b);
+}
+
+__m128 test_cmpngt_ss(__m128 a, __m128 b) {
+ // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 5)
+ // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
+ return _mm_cmpngt_ss(a, b);
+}
+
+__m128 test_cmpnge_ss(__m128 a, __m128 b) {
+ // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 6)
+ // CHECK: shufflevector <{{.*}}, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
+ return _mm_cmpnge_ss(a, b);
+}
+
+__m128d test_cmpgt_sd(__m128d a, __m128d b) {
+ // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 1)
+ // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
+ return _mm_cmpgt_sd(a, b);
+}
+
+__m128d test_cmpge_sd(__m128d a, __m128d b) {
+ // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 2)
+ // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
+ return _mm_cmpge_sd(a, b);
+}
+
+__m128d test_cmpngt_sd(__m128d a, __m128d b) {
+ // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 5)
+ // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
+ return _mm_cmpngt_sd(a, b);
+}
+
+__m128d test_cmpnge_sd(__m128d a, __m128d b) {
+ // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 6)
+ // CHECK: shufflevector <{{.*}}, <2 x i32> <i32 0, i32 3>
+ return _mm_cmpnge_sd(a, b);
+}