1
+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fclangir -emit-cir -o %t.cir -Wall -Werror
2
+ // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s
3
+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror
4
+ // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s
5
+
6
+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fclangir -emit-llvm -o %t.ll -Wall -Werror
7
+ // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
8
+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
9
+ // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
10
+
11
+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fclangir -emit-cir -o %t.cir -Wall -Werror
12
+ // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s
13
+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror
14
+ // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s
15
+
16
+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fclangir -emit-llvm -o %t.ll -Wall -Werror
17
+ // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
18
+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx2 -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
19
+ // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
20
+
21
+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
22
+ // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
23
+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
24
+ // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=OGCG
25
+
26
+ // This test mimics clang/test/CodeGen/X86/avx2-builtins.c, which eventually
27
+ // CIR shall be able to support fully.
28
+
29
+ #include <immintrin.h>
30
+
31
+ // FIXME: We should also lower the __builtin_ia32_pblendw128 (and similar)
32
+ // functions to this IR. In the future we could delete the corresponding
33
+ // intrinsic in LLVM if it's not being used anymore.
34
+ __m256i test_mm256_blend_epi16 (__m256i a , __m256i b ) {
35
+ // CIR-LABEL: _mm256_blend_epi16
36
+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!s16i x 16>) [#cir.int<0> : !s32i, #cir.int<17> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i, #cir.int<8> : !s32i, #cir.int<25> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<12> : !s32i, #cir.int<13> : !s32i, #cir.int<14> : !s32i, #cir.int<15> : !s32i] : !cir.vector<!s16i x 16>
37
+
38
+ // LLVM-LABEL: test_mm256_blend_epi16
39
+ // LLVM-NOT: @llvm.x86.avx2.pblendw
40
+ // LLVM: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 0, i32 17, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 25, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
41
+
42
+ // OGCG-LABEL: test_mm256_blend_epi16
43
+ // OGCG-NOT: @llvm.x86.avx2.pblendw
44
+ // OGCG: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 0, i32 17, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 25, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
45
+ return _mm256_blend_epi16 (a , b , 2 );
46
+ }
47
+
48
+ __m128i test_mm_blend_epi32 (__m128i a , __m128i b ) {
49
+ // CIR-LABEL: _mm_blend_epi32
50
+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!s32i x 4>) [#cir.int<4> : !s32i, #cir.int<1> : !s32i, #cir.int<6> : !s32i, #cir.int<3> : !s32i] : !cir.vector<!s32i x 4>
51
+
52
+ // LLVM-LABEL: test_mm_blend_epi32
53
+ // LLVM-NOT: @llvm.x86.avx2.pblendd.128
54
+ // LLVM: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
55
+
56
+ // OGCG-LABEL: test_mm_blend_epi32
57
+ // OGCG-NOT: @llvm.x86.avx2.pblendd.128
58
+ // OGCG: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
59
+ return _mm_blend_epi32 (a , b , 0x05 );
60
+ }
61
+
62
+ __m256i test_mm256_blend_epi32 (__m256i a , __m256i b ) {
63
+ // CIR-LABEL: _mm256_blend_epi32
64
+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!s32i x 8>) [#cir.int<8> : !s32i, #cir.int<1> : !s32i, #cir.int<10> : !s32i, #cir.int<3> : !s32i, #cir.int<12> : !s32i, #cir.int<13> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<!s32i x 8>
65
+
66
+ // LLVM-LABEL: test_mm256_blend_epi32
67
+ // LLVM-NOT: @llvm.x86.avx2.pblendd.256
68
+ // LLVM: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 8, i32 1, i32 10, i32 3, i32 12, i32 13, i32 6, i32 7>
69
+
70
+ // OGCG-LABEL: test_mm256_blend_epi32
71
+ // OGCG-NOT: @llvm.x86.avx2.pblendd.256
72
+ // OGCG: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 8, i32 1, i32 10, i32 3, i32 12, i32 13, i32 6, i32 7>
73
+ return _mm256_blend_epi32 (a , b , 0x35 );
74
+ }
0 commit comments