1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: A: 4*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: vunpck 5*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertf128 $1 6*9880d681SAndroid Build Coastguard Workerdefine <8 x float> @A(<8 x float> %a) nounwind uwtable readnone ssp { 7*9880d681SAndroid Build Coastguard Workerentry: 8*9880d681SAndroid Build Coastguard Worker %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*9880d681SAndroid Build Coastguard Worker ret <8 x float> %shuffle 10*9880d681SAndroid Build Coastguard Worker} 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: B: 13*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: vunpck 14*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertf128 $1 15*9880d681SAndroid Build Coastguard Workerdefine <4 x double> @B(<4 x double> %a) nounwind uwtable readnone ssp { 16*9880d681SAndroid Build Coastguard Workerentry: 17*9880d681SAndroid Build Coastguard Worker %shuffle = shufflevector <4 x double> %a, <4 x double> undef, <4 x i32> <i32 4, i32 4, i32 0, i32 1> 18*9880d681SAndroid Build Coastguard Worker ret <4 x double> %shuffle 19*9880d681SAndroid Build Coastguard Worker} 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerdeclare <2 x double> @llvm.x86.sse2.min.pd(<2 x double>, <2 x double>) nounwind readnone 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Workerdeclare <2 x double> @llvm.x86.sse2.min.sd(<2 x double>, <2 x double>) nounwind readnone 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; Just check that no crash happens 26*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _insert_crash: 27*9880d681SAndroid Build Coastguard Workerdefine void @insert_crash() nounwind { 28*9880d681SAndroid Build Coastguard Workerallocas: 29*9880d681SAndroid Build Coastguard Worker %v1.i.i451 = shufflevector <4 x double> zeroinitializer, <4 x double> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> 30*9880d681SAndroid Build Coastguard Worker %ret_0a.i.i.i452 = shufflevector <4 x double> %v1.i.i451, <4 x double> undef, <2 x i32> <i32 0, i32 1> 31*9880d681SAndroid Build Coastguard Worker %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*9880d681SAndroid Build Coastguard Worker %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*9880d681SAndroid Build Coastguard Worker %ret.i1.i.i464 = extractelement <2 x double> %ret_val.i.i.i463, i32 0 34*9880d681SAndroid Build Coastguard Worker %double2float = fptrunc double %ret.i1.i.i464 to float 35*9880d681SAndroid Build Coastguard Worker %smearinsert50 = insertelement <4 x float> undef, float %double2float, i32 3 36*9880d681SAndroid Build Coastguard Worker %blendAsInt.i503 = bitcast <4 x float> %smearinsert50 to <4 x i32> 37*9880d681SAndroid Build Coastguard Worker store <4 x i32> %blendAsInt.i503, <4 x i32>* undef, align 4 38*9880d681SAndroid Build Coastguard Worker ret void 39*9880d681SAndroid Build Coastguard Worker} 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker;; DAG Combine must remove useless vinsertf128 instructions 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: DAGCombineA: 44*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: vinsertf128 $1 45*9880d681SAndroid Build Coastguard Workerdefine <4 x i32> @DAGCombineA(<4 x i32> %v1) nounwind readonly { 46*9880d681SAndroid Build Coastguard Worker %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*9880d681SAndroid Build Coastguard Worker %2 = shufflevector <8 x i32> %1, <8 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3> 48*9880d681SAndroid Build Coastguard Worker ret <4 x i32> %2 49*9880d681SAndroid Build Coastguard Worker} 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: DAGCombineB: 52*9880d681SAndroid Build Coastguard Worker; CHECK: vpaddd %xmm 53*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: vinsertf128 $1 54*9880d681SAndroid Build Coastguard Worker; CHECK: vpaddd %xmm 55*9880d681SAndroid Build Coastguard Workerdefine <8 x i32> @DAGCombineB(<8 x i32> %v1, <8 x i32> %v2) nounwind readonly { 56*9880d681SAndroid Build Coastguard Worker %1 = add <8 x i32> %v1, %v2 57*9880d681SAndroid Build Coastguard Worker %2 = add <8 x i32> %1, %v1 58*9880d681SAndroid Build Coastguard Worker ret <8 x i32> %2 59*9880d681SAndroid Build Coastguard Worker} 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insert_undef_pd: 62*9880d681SAndroid Build Coastguard Workerdefine <4 x double> @insert_undef_pd(<4 x double> %a0, <2 x double> %a1) { 63*9880d681SAndroid Build Coastguard Worker; CHECK: vmovaps %ymm1, %ymm0 64*9880d681SAndroid Build Coastguard Worker%res = call <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double> undef, <2 x double> %a1, i8 0) 65*9880d681SAndroid Build Coastguard Workerret <4 x double> %res 66*9880d681SAndroid Build Coastguard Worker} 67*9880d681SAndroid Build Coastguard Workerdeclare <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double>, <2 x double>, i8) nounwind readnone 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insert_undef_ps: 71*9880d681SAndroid Build Coastguard Workerdefine <8 x float> @insert_undef_ps(<8 x float> %a0, <4 x float> %a1) { 72*9880d681SAndroid Build Coastguard Worker; CHECK: vmovaps %ymm1, %ymm0 73*9880d681SAndroid Build Coastguard Worker%res = call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> undef, <4 x float> %a1, i8 0) 74*9880d681SAndroid Build Coastguard Workerret <8 x float> %res 75*9880d681SAndroid Build Coastguard Worker} 76*9880d681SAndroid Build Coastguard Workerdeclare <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float>, <4 x float>, i8) nounwind readnone 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Worker 79*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insert_undef_si: 80*9880d681SAndroid Build Coastguard Workerdefine <8 x i32> @insert_undef_si(<8 x i32> %a0, <4 x i32> %a1) { 81*9880d681SAndroid Build Coastguard Worker; CHECK: vmovaps %ymm1, %ymm0 82*9880d681SAndroid Build Coastguard Worker%res = call <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32> undef, <4 x i32> %a1, i8 0) 83*9880d681SAndroid Build Coastguard Workerret <8 x i32> %res 84*9880d681SAndroid Build Coastguard Worker} 85*9880d681SAndroid Build Coastguard Workerdeclare <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32>, <4 x i32>, i8) nounwind readnone 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Worker; rdar://10643481 88*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vinsertf128_combine: 89*9880d681SAndroid Build Coastguard Workerdefine <8 x float> @vinsertf128_combine(float* nocapture %f) nounwind uwtable readonly ssp { 90*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: vmovaps 91*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertf128 92*9880d681SAndroid Build Coastguard Workerentry: 93*9880d681SAndroid Build Coastguard Worker %add.ptr = getelementptr inbounds float, float* %f, i64 4 94*9880d681SAndroid Build Coastguard Worker %0 = bitcast float* %add.ptr to <4 x float>* 95*9880d681SAndroid Build Coastguard Worker %1 = load <4 x float>, <4 x float>* %0, align 16 96*9880d681SAndroid Build Coastguard Worker %2 = tail call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> undef, <4 x float> %1, i8 1) 97*9880d681SAndroid Build Coastguard Worker ret <8 x float> %2 98*9880d681SAndroid Build Coastguard Worker} 99*9880d681SAndroid Build Coastguard Worker 100*9880d681SAndroid Build Coastguard Worker; rdar://11076953 101*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: vinsertf128_ucombine: 102*9880d681SAndroid Build Coastguard Workerdefine <8 x float> @vinsertf128_ucombine(float* nocapture %f) nounwind uwtable readonly ssp { 103*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: vmovups 104*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertf128 105*9880d681SAndroid Build Coastguard Workerentry: 106*9880d681SAndroid Build Coastguard Worker %add.ptr = getelementptr inbounds float, float* %f, i64 4 107*9880d681SAndroid Build Coastguard Worker %0 = bitcast float* %add.ptr to <4 x float>* 108*9880d681SAndroid Build Coastguard Worker %1 = load <4 x float>, <4 x float>* %0, align 8 109*9880d681SAndroid Build Coastguard Worker %2 = tail call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> undef, <4 x float> %1, i8 1) 110*9880d681SAndroid Build Coastguard Worker ret <8 x float> %2 111*9880d681SAndroid Build Coastguard Worker} 112