Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/X86/align-builtins.c

raw
1 // RUN: %clang_cc1 -x c -ffreestanding -triple x86_64-unknown-linux -target-feature +avx512vl -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64-unknown-linux -target-feature +avx512vl -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s
4 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
5
6 // RUN: %clang_cc1 -x c -ffreestanding -triple x86_64-unknown-linux -target-feature +avx512vl -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
7 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
8 // RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64-unknown-linux -target-feature +avx512vl -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
9 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
10
11 // RUN: %clang_cc1 -x c -ffreestanding -triple=x86_64-unknown-linux -target-feature +avx512vl -emit-llvm -Wall -Werror %s -o - | FileCheck %s -check-prefix=OGCG
12 // RUN: %clang_cc1 -x c++ -ffreestanding -triple=x86_64-unknown-linux -target-feature +avx512vl -emit-llvm -Wall -Werror %s -o - | FileCheck %s -check-prefix=OGCG
13
14 #include <immintrin.h>
15
16 __v4si test_builtin_ia32_alignd128()
17 {
18 // CIR-LABEL: _builtin_ia32_alignd128
19 // CIR: cir.vec.shuffle({{%.*}}, {{%.*}} : !cir.vector<4 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !s32i>
20
21 // LLVM-LABEL: test_builtin_ia32_alignd128
22 // LLVM: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
23
24 // OGCG-LABEL: test_builtin_ia32_alignd128
25 // OGCG: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
26 __v4si vec1 = {0, 1, 2, 3};
27 __v4si vec2 = {4, 5, 6, 7};
28 return __builtin_ia32_alignd128(vec1, vec2, 0);
29 }
30
31 __v8si test_builtin_ia32_alignd256()
32 {
33 // CIR-LABEL: _builtin_ia32_alignd256
34 // CIR: cir.vec.shuffle({{%.*}}, {{%.*}} : !cir.vector<8 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !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.vector<8 x !s32i>
35 // LLVM-LABEL: test_builtin_ia32_alignd256
36 // LLVM: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
37 // OGCG-LABEL: test_builtin_ia32_alignd256
38 // OGCG: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
39 __v8si vec1 = {0, 1, 2, 3, 4, 5, 6, 7};
40 __v8si vec2 = {8, 9, 10, 11, 12, 13, 14, 15};
41 return __builtin_ia32_alignd256(vec1, vec2, 0);
42 }
43
44 __v16si test_builtin_ia32_alignd512()
45 {
46 // CIR-LABEL: _builtin_ia32_alignd512
47 // CIR: cir.vec.shuffle({{%.*}}, {{%.*}} : !cir.vector<16 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !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<9> : !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<16 x !s32i>
48 // LLVM-LABEL: test_builtin_ia32_alignd512
49 // LLVM: shufflevector <16 x i32> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
50 // OGCG-LABEL: test_builtin_ia32_alignd512
51 // OGCG: shufflevector <16 x i32> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
52 __v16si vec1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
53 __v16si vec2 = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
54 return __builtin_ia32_alignd512(vec1, vec2, 0);
55 }
56
57 __v2di test_builtin_ia32_alignq128()
58 {
59 // CIR-LABEL: _builtin_ia32_alignq128
60 // CIR: cir.vec.shuffle({{%.*}}, {{%.*}} : !cir.vector<2 x !s64i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i] : !cir.vector<2 x !s64i>
61 // LLVM-LABEL: test_builtin_ia32_alignq128
62 // LLVM: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> <i32 0, i32 1>
63 // OGCG-LABEL: test_builtin_ia32_alignq128
64 // OGCG: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> <i32 0, i32 1>
65 __v2di vec1 = {0, 1};
66 __v2di vec2 = {2, 3};
67 return __builtin_ia32_alignq128(vec1, vec2, 0);
68 }
69
70 __v4di test_builtin_ia32_alignq256()
71 {
72 // CIR-LABEL: _builtin_ia32_alignq256
73 // CIR: cir.vec.shuffle({{%.*}}, {{%.*}} : !cir.vector<4 x !s64i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !s64i>
74 // LLVM-LABEL: test_builtin_ia32_alignq256
75 // LLVM: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
76 // OGCG-LABEL: test_builtin_ia32_alignq256
77 // OGCG: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
78 __v4di vec1 = {0, 1, 2, 3};
79 __v4di vec2 = {4, 5, 6, 7};
80 return __builtin_ia32_alignq256(vec1, vec2, 0);
81 }
82
83 __v8di test_builtin_ia32_alignq512()
84 {
85 // CIR-LABEL: _builtin_ia32_alignq512
86 // CIR: cir.vec.shuffle({{%.*}}, {{%.*}} : !cir.vector<8 x !s64i>) [#cir.int<0> : !s32i, #cir.int<1> : !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.vector<8 x !s64i>
87 // LLVM-LABEL: test_builtin_ia32_alignq512
88 // LLVM: shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
89 // OGCG-LABEL: test_builtin_ia32_alignq512
90 // OGCG: shufflevector <8 x i64> %{{.*}}, <8 x i64> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
91 __v8di vec1 = {0, 1, 2, 3, 4, 5, 6, 7};
92 __v8di vec2 = {8, 9, 10, 11, 12, 13, 14, 15};
93 return __builtin_ia32_alignq512(vec1, vec2, 0);
94 }