1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx | FileCheck %s
5 ; CHECK: vinsertf128 $1
6 define <8 x float> @A(<8 x float> %a) nounwind uwtable readnone ssp {
8 %shuffle = shufflevector <8 x float> %a, <8 x float> undef, <8 x i32> <i32 8, i32 8, i32 8, i32 8, i32 0, i32 1, i32 2, i32 3>
9 ret <8 x float> %shuffle
14 ; CHECK: vinsertf128 $1
15 define <4 x double> @B(<4 x double> %a) nounwind uwtable readnone ssp {
17 %shuffle = shufflevector <4 x double> %a, <4 x double> undef, <4 x i32> <i32 4, i32 4, i32 0, i32 1>
18 ret <4 x double> %shuffle
21 declare <2 x double> @llvm.x86.sse2.min.pd(<2 x double>, <2 x double>) nounwind readnone
23 declare <2 x double> @llvm.x86.sse2.min.sd(<2 x double>, <2 x double>) nounwind readnone
25 ; Just check that no crash happens
26 ; CHECK-LABEL: _insert_crash:
27 define void @insert_crash() nounwind {
29 %v1.i.i451 = shufflevector <4 x double> zeroinitializer, <4 x double> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
30 %ret_0a.i.i.i452 = shufflevector <4 x double> %v1.i.i451, <4 x double> undef, <2 x i32> <i32 0, i32 1>
31 %vret_0.i.i.i454 = tail call <2 x double> @llvm.x86.sse2.min.pd(<2 x double> %ret_0a.i.i.i452, <2 x double> undef) nounwind
32 %ret_val.i.i.i463 = tail call <2 x double> @llvm.x86.sse2.min.sd(<2 x double> %vret_0.i.i.i454, <2 x double> undef) nounwind
33 %ret.i1.i.i464 = extractelement <2 x double> %ret_val.i.i.i463, i32 0
34 %double2float = fptrunc double %ret.i1.i.i464 to float
35 %smearinsert50 = insertelement <4 x float> undef, float %double2float, i32 3
36 %blendAsInt.i503 = bitcast <4 x float> %smearinsert50 to <4 x i32>
37 store <4 x i32> %blendAsInt.i503, <4 x i32>* undef, align 4
41 ;; DAG Combine must remove useless vinsertf128 instructions
43 ; CHECK-LABEL: DAGCombineA:
44 ; CHECK-NOT: vinsertf128 $1
45 define <4 x i32> @DAGCombineA(<4 x i32> %v1) nounwind readonly {
46 %1 = shufflevector <4 x i32> %v1, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
47 %2 = shufflevector <8 x i32> %1, <8 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
51 ; CHECK-LABEL: DAGCombineB:
53 ; CHECK-NOT: vinsertf128 $1
55 define <8 x i32> @DAGCombineB(<8 x i32> %v1, <8 x i32> %v2) nounwind readonly {
56 %1 = add <8 x i32> %v1, %v2
57 %2 = add <8 x i32> %1, %v1
61 ; CHECK-LABEL: insert_undef_pd:
62 define <4 x double> @insert_undef_pd(<4 x double> %a0, <2 x double> %a1) {
63 ; CHECK: vmovaps %ymm1, %ymm0
64 %res = call <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double> undef, <2 x double> %a1, i8 0)
67 declare <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double>, <2 x double>, i8) nounwind readnone
70 ; CHECK-LABEL: insert_undef_ps:
71 define <8 x float> @insert_undef_ps(<8 x float> %a0, <4 x float> %a1) {
72 ; CHECK: vmovaps %ymm1, %ymm0
73 %res = call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> undef, <4 x float> %a1, i8 0)
76 declare <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float>, <4 x float>, i8) nounwind readnone
79 ; CHECK-LABEL: insert_undef_si:
80 define <8 x i32> @insert_undef_si(<8 x i32> %a0, <4 x i32> %a1) {
81 ; CHECK: vmovaps %ymm1, %ymm0
82 %res = call <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32> undef, <4 x i32> %a1, i8 0)
85 declare <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32>, <4 x i32>, i8) nounwind readnone
88 ; CHECK-LABEL: vinsertf128_combine:
89 define <8 x float> @vinsertf128_combine(float* nocapture %f) nounwind uwtable readonly ssp {
93 %add.ptr = getelementptr inbounds float, float* %f, i64 4
94 %0 = bitcast float* %add.ptr to <4 x float>*
95 %1 = load <4 x float>, <4 x float>* %0, align 16
96 %2 = tail call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> undef, <4 x float> %1, i8 1)
101 ; CHECK-LABEL: vinsertf128_ucombine:
102 define <8 x float> @vinsertf128_ucombine(float* nocapture %f) nounwind uwtable readonly ssp {
106 %add.ptr = getelementptr inbounds float, float* %f, i64 4
107 %0 = bitcast float* %add.ptr to <4 x float>*
108 %1 = load <4 x float>, <4 x float>* %0, align 8
109 %2 = tail call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> undef, <4 x float> %1, i8 1)