11// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fclangir -emit-cir -o %t.cir -Wall -Werror
2- // RUN: FileCheck --check-prefixes=CIR-CHECK --input-file=%t.cir %s
2+ // RUN: FileCheck --check-prefixes=CIR-CHECK,CIR-X64 --input-file=%t.cir %s
33// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror
4- // RUN: FileCheck --check-prefixes=CIR-CHECK --input-file=%t.cir %s
4+ // RUN: FileCheck --check-prefixes=CIR-CHECK,CIR-X64 --input-file=%t.cir %s
55
66// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fclangir -emit-llvm -o %t.ll -Wall -Werror
7- // RUN: FileCheck --check-prefixes=LLVM-CHECK --input-file=%t.ll %s
7+ // RUN: FileCheck --check-prefixes=LLVM-CHECK,LLVM-X64 --input-file=%t.ll %s
88// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
9- // RUN: FileCheck --check-prefixes=LLVM-CHECK --input-file=%t.ll %s
9+ // RUN: FileCheck --check-prefixes=LLVM-CHECK,LLVM-X64 --input-file=%t.ll %s
10+
11+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
12+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
13+
14+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
15+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
1016
1117// This test mimics clang/test/CodeGen/X86/sse2-builtins.c, which eventually
1218// CIR shall be able to support fully.
@@ -21,6 +27,44 @@ void test_mm_clflush(void* A) {
2127 // LLVM-CHECK: call void @llvm.x86.sse2.clflush(ptr {{%.*}})
2228}
2329
30+ __m128d test_mm_undefined_pd (void ) {
31+ // CIR-X64-LABEL: _mm_undefined_pd
32+ // CIR-X64: %{{.*}} = cir.const #cir.zero : !cir.vector<2 x !cir.double>
33+ // CIR-X64: cir.return %{{.*}} : !cir.vector<2 x !cir.double>
34+
35+ // LLVM-X64-LABEL: test_mm_undefined_pd
36+ // LLVM-X64: store <2 x double> zeroinitializer, ptr %[[A:.*]], align 16
37+ // LLVM-X64: %{{.*}} = load <2 x double>, ptr %[[A]], align 16
38+ // LLVM-X64: ret <2 x double> %{{.*}}
39+ return _mm_undefined_pd ();
40+ }
41+
42+ __m128i test_mm_undefined_si128 (void ) {
43+ // CIR-LABEL: _mm_undefined_si128
44+ // CIR-CHECK: %[[A:.*]] = cir.const #cir.zero : !cir.vector<2 x !cir.double>
45+ // CIR-CHECK: %{{.*}} = cir.cast bitcast %[[A]] : !cir.vector<2 x !cir.double> -> !cir.vector<2 x !s64i>
46+ // CIR-CHECK: cir.return %{{.*}} : !cir.vector<2 x !s64i>
47+
48+ // LLVM-CHECK-LABEL: test_mm_undefined_si128
49+ // LLVM-CHECK: store <2 x i64> zeroinitializer, ptr %[[A:.*]], align 16
50+ // LLVM-CHECK: %{{.*}} = load <2 x i64>, ptr %[[A]], align 16
51+ // LLVM-CHECK: ret <2 x i64> %{{.*}}
52+ return _mm_undefined_si128 ();
53+ }
54+
55+ // Lowering to pextrw requires optimization.
56+ int test_mm_extract_epi16 (__m128i A ) {
57+
58+ // CIR-CHECK-LABEL: test_mm_extract_epi16
59+ // CIR-CHECK %{{.*}} = cir.vec.extract %{{.*}}[%{{.*}} : {{!u32i|!u64i}}] : !cir.vector<!s16i x 8>
60+ // CIR-CHECK %{{.*}} = cir.cast integral %{{.*}} : !u16i -> !s32i
61+
62+ // LLVM-CHECK-LABEL: test_mm_extract_epi16
63+ // LLVM-CHECK: extractelement <8 x i16> %{{.*}}, {{i32|i64}} 1
64+ // LLVM-CHECK: zext i16 %{{.*}} to i32
65+ return _mm_extract_epi16 (A , 1 );
66+ }
67+
2468void test_mm_lfence (void ) {
2569 // CIR-CHECK-LABEL: test_mm_lfence
2670 // LLVM-CHECK-LABEL: test_mm_lfence
@@ -35,4 +79,40 @@ void test_mm_mfence(void) {
3579 _mm_mfence ();
3680 // CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.mfence" : () -> !void
3781 // LLVM-CHECK: call void @llvm.x86.sse2.mfence()
38- }
82+ }
83+
84+ __m128i test_mm_shufflelo_epi16 (__m128i A ) {
85+ // CIR-LABEL: _mm_shufflelo_epi16
86+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!s16i x 8>) [#cir.int<0> : !s32i, #cir.int<0> : !s32i, #cir.int<0> : !s32i, #cir.int<0> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<!s16i x 8>
87+
88+ // LLVM-LABEL: test_mm_shufflelo_epi16
89+ // LLVM: shufflevector <8 x i16> %{{.*}}, <8 x i16> poison, <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 4, i32 5, i32 6, i32 7>
90+
91+ // OGCG-LABEL: test_mm_shufflelo_epi16
92+ // OGCG: shufflevector <8 x i16> %{{.*}}, <8 x i16> poison, <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 4, i32 5, i32 6, i32 7>
93+ return _mm_shufflelo_epi16 (A , 0 );
94+ }
95+
96+ __m128i test_mm_shufflehi_epi16 (__m128i A ) {
97+ // CIR-LABEL: _mm_shufflehi_epi16
98+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!s16i x 8>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<4> : !s32i, #cir.int<4> : !s32i, #cir.int<4> : !s32i] : !cir.vector<!s16i x 8>
99+
100+ // LLVM-LABEL: test_mm_shufflehi_epi16
101+ // LLVM: shufflevector <8 x i16> %{{.*}}, <8 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 4, i32 4, i32 4>
102+
103+ // OGCG-LABEL: test_mm_shufflehi_epi16
104+ // OGCG: shufflevector <8 x i16> %{{.*}}, <8 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 4, i32 4, i32 4>
105+ return _mm_shufflehi_epi16 (A , 0 );
106+ }
107+
108+ __m128d test_mm_shuffle_pd (__m128d A , __m128d B ) {
109+ // CIR-LABEL: test_mm_shuffle_pd
110+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!cir.double x 2>) [#cir.int<1> : !s32i, #cir.int<2> : !s32i] : !cir.vector<!cir.double x 2>
111+
112+ // CHECK-LABEL: test_mm_shuffle_pd
113+ // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> <i32 1, i32 2>
114+
115+ // OGCG-LABEL: test_mm_shuffle_pd
116+ // OGCG: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> <i32 1, i32 2>
117+ return _mm_shuffle_pd (A , B , 1 );
118+ }
0 commit comments