1+ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2+ // REQUIRES: x86-registered-target
3+ // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx -disable-O0-optnone -fclangir -emit-cir -o %t.cir | opt -S -passes=mem2reg
4+ // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s
5+
6+ // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx -disable-O0-optnone -fclangir -emit-llvm -o %t.ll | opt -S -passes=mem2reg
7+ // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
8+
9+ #include <immintrin.h>
10+
11+ // CIR-LABEL: @test_mm256_insertf128_pd_0(
12+ // CIR: [[A:%.*]] = cir.load align(32) %0 : !cir.ptr<!cir.vector<!cir.double x 4>>, !cir.vector<!cir.double x 4>
13+ // CIR: [[B:%.*]] = cir.load align(16) %1 : !cir.ptr<!cir.vector<!cir.double x 2>>, !cir.vector<!cir.double x 2>
14+ // CIR: %{{.*}} = cir.vec.shuffle([[B]], %{{.*}} : !cir.vector<!cir.double x 2>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<!cir.double x 4>
15+ // CIR-NEXT: %{{.*}} = cir.vec.shuffle([[A]], %{{.*}} : !s32i, #cir.int<5> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<!cir.double x 4>
16+ // CIR: cir.return %{{.*}} : !cir.vector<!cir.double x 4>
17+
18+
19+ // LLVM-LABEL: @test_mm256_insertf128_pd_0
20+ // LLVM: [[A:%.*]] = load <4 x double>, ptr %{{.*}}, align 32
21+ // LLVM: [[B:%.*]] = load <2 x double>, ptr %{{.*}}, align 16
22+ // LLVM-NEXT: [[WIDEN:%.*]] = shufflevector <2 x double> [[B]], <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
23+ // LLVM-NEXT: [[INSERT:%.*]] = shufflevector <4 x double> [[A]], <4 x double> [[WIDEN]], <4 x i32> <i32 4, i32 5, i32 2, i32 3>
24+ // LLVM: ret <4 x double>
25+ __m256d test_mm256_insertf128_pd_0 (__m256d a , __m128d b ) {
26+ return _mm256_insertf128_pd (a , b , 0 );
27+ }
28+
29+ // CIR-LABEL: @test_mm256_insertf128_pd_1(
30+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!cir.float x 4>) [#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<!cir.float x 8>
31+ // CIR-NEXT: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!cir.float x 8>) [#cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i] : !cir.vector<!cir.float x 8>
32+ // CIR: cir.return %{{.*}} : !cir.vector<!cir.float x 8>
33+
34+ // LLVM-LABEL: @test_mm256_insertf128_ps_0(
35+ // LLVM-NEXT: %{{.*}} = shufflevector <4 x float> %{{.*}}, <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
36+ // LLVM-NEXT: %{{.*}} = shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7>
37+ // LLVM-NEXT: ret <8 x float> %{{.*}}
38+ //
39+ __m256 test_mm256_insertf128_ps_0 (__m256 a , __m128 b ) {
40+ return _mm256_insertf128_ps (a , b , 0 );
41+ }
42+
43+ // CIR-LABEL: @test_mm256_insertf128_ps_1(
44+ // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!cir.float x 4>) [#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<!cir.float x 8>
45+ // CIR-NEXT: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<!cir.float x 8>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<!cir.float x 8>
46+ // CIR: cir.return %{{.*}} : !cir.vector<!cir.float x 8>
47+
48+ // LLVM-LABEL: define dso_local <8 x float> @test_mm256_insertf128_ps_1(
49+ // LLVM: %{{.*}} = shufflevector <4 x float> %{{.*}}, <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
50+ // LLVM-NEXT: %{{.*}} = shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
51+ // LLVM: ret <8 x float> %{{.*}}
52+ //
53+ __m256 test_mm256_insertf128_ps_1 (__m256 a , __m128 b ) {
54+ return _mm256_insertf128_ps (a , b , 1 );
55+ }
56+
57+ // CIR-LABEL: @test_mm256_insertf128_si256_0(
58+ // CIR: [[TMP0:%.*]] = cir.cast(bitcast, %{{.*}} : !cir.vector<!s64i x 4>), !cir.vector<!s32i x 8>
59+ // CIR: [[TMP1:%.*]] = cir.cast(bitcast, %{{.*}} : !cir.vector<!s64i x 2>), !cir.vector<!s32i x 4>
60+ // CIR: %{{.*}} = cir.vec.shuffle([[TMP1]], %{{.*}} : !cir.vector<!cir.float x 4>) [#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<!cir.float x 8>
61+ // CIR-NEXT: %{{.*}} = cir.vec.shuffle([[TMP0]], %{{.*}} : !cir.vector<!cir.float x 8>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<!cir.float x 8>
62+ // CIR: %{{.*}} = cir.cast(bitcast, %{{.*}} : !cir.vector<!s32i x 8>), !cir.vector<!s64i x 4>
63+ // CIR: cir.return %{{.*}} : !cir.vector<!s64i x 4>
64+
65+ // LLVM-LABEL: @test_mm256_insertf128_si256_0
66+ // LLVM-NEXT: [[TMP0:%.*]] = bitcast <4 x i64> %{{.*}} to <8 x i32>
67+ // LLVM-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32>
68+ // LLVM-NEXT: [[WIDEN:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
69+ // LLVM-NEXT: [[INSERT:%.*]] = shufflevector <8 x i32> [[TMP0]], <8 x i32> [[WIDEN]], <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 4, i32 5, i32 6, i32 7>
70+ // LLVM-NEXT: [[TMP2:%.*]] = bitcast <8 x i32> [[INSERT]] to <4 x i64>
71+ // LLVM-NEXT: ret <4 x i64> %{{.*}}
72+ //
73+ __m256i test_mm256_insertf128_si256_0 (__m256i a , __m128i b ) {
74+ return _mm256_insertf128_si256 (a , b , 0 );
75+ }
76+
77+ // CIR-LABEL: @test_mm256_insertf128_si256_1(
78+ // CIR: [[TMP0:%.*]] = cir.cast(bitcast, %{{.*}} : !cir.vector<!s64i x 4>), !cir.vector<!s32i x 8>
79+ // CIR: [[TMP1:%.*]] = cir.cast(bitcast, %{{.*}} : !cir.vector<!s64i x 2>), !cir.vector<!s32i x 4>
80+ // CIR: %{{.*}} = cir.vec.shuffle([[TMP1]], %{{.*}} : !cir.vector<!cir.float x 4>) [#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<!cir.float x 8>
81+ // CIR-NEXT: %{{.*}} = cir.vec.shuffle([[TMP0]], %{{.*}} : !cir.vector<!cir.float x 8>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<!cir.float x 8>
82+ // CIR: %{{.*}} = cir.cast(bitcast, %{{.*}} : !cir.vector<!s32i x 8>), !cir.vector<!s64i x 4>
83+ // CIR: cir.return %{{.*}} : !cir.vector<!s64i x 4>
84+
85+ // LLVM-LABEL: @test_mm256_insertf128_si256_1
86+ // LLVM-NEXT: [[TMP0:%.*]] = bitcast <4 x i64> %{{.*}} to <8 x i32>
87+ // LLVM-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32>
88+ // LLVM-NEXT: [[WIDEN:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
89+ // LLVM-NEXT: [[INSERT:%.*]] = shufflevector <8 x i32> [[TMP0]], <8 x i32> [[WIDEN]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
90+ // LLVM-NEXT: [[TMP2:%.*]] = bitcast <8 x i32> [[INSERT]] to <4 x i64>
91+ // LLVM-NEXT: ret <4 x i64> %{{.*}}
92+ //
93+ __m256i test_mm256_insertf128_si256_1 (__m256i a , __m128i b ) {
94+ return _mm256_insertf128_si256 (a , b , 1 );
95+ }
0 commit comments