1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s
4 define <4 x float> @test1(<4 x float> %a) nounwind {
5 %b = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 2, i32 5, i32 undef, i32 undef>
13 define <3 x i64> @test2(<2 x i64> %v) nounwind readnone {
16 %1 = shufflevector <2 x i64> %v, <2 x i64> %v, <3 x i32> <i32 0, i32 1, i32 undef>
17 %2 = shufflevector <3 x i64> zeroinitializer, <3 x i64> %1, <3 x i32> <i32 3, i32 4, i32 2>
22 define <4 x i64> @test3(<4 x i64> %a, <4 x i64> %b) nounwind {
23 %c = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 4, i32 5, i32 2, i32 undef>
30 define <8 x float> @test4(float %a) nounwind {
31 %b = insertelement <8 x float> zeroinitializer, float %a, i32 0
38 define <8 x float> @test5(float* nocapture %f) nounwind uwtable readonly ssp {
40 %0 = bitcast float* %f to <4 x float>*
41 %1 = load <4 x float>* %0, align 16
45 ; CHECK-NOT: vinsertf128
46 %shuffle.i = shufflevector <4 x float> %1, <4 x float> <float 0.000000e+00, float undef, float undef, float undef>, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 4, i32 4, i32 4>
47 ret <8 x float> %shuffle.i
50 define <4 x double> @test6(double* nocapture %d) nounwind uwtable readonly ssp {
52 %0 = bitcast double* %d to <2 x double>*
53 %1 = load <2 x double>* %0, align 16
57 ; CHECK-NOT: vinsertf128
58 %shuffle.i = shufflevector <2 x double> %1, <2 x double> <double 0.000000e+00, double undef>, <4 x i32> <i32 0, i32 1, i32 2, i32 2>
59 ret <4 x double> %shuffle.i
62 define <16 x i16> @test7(<4 x i16> %a) nounwind {
64 %b = shufflevector <4 x i16> %a, <4 x i16> undef, <16 x i32> <i32 1, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
70 define void @test8() {
72 %0 = load <16 x i64> addrspace(1)* null, align 128
73 %1 = shufflevector <16 x i64> <i64 undef, i64 undef, i64 0, i64 undef, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 undef, i64 0, i64 undef, i64 undef, i64 undef, i64 undef>, <16 x i64> %0, <16 x i32> <i32 17, i32 18, i32 2, i32 undef, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 undef, i32 11, i32 undef, i32 undef, i32 undef, i32 26>
74 %2 = shufflevector <16 x i64> %1, <16 x i64> %0, <16 x i32> <i32 0, i32 1, i32 2, i32 30, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 undef, i32 11, i32 undef, i32 22, i32 20, i32 15>
75 store <16 x i64> %2, <16 x i64> addrspace(1)* undef, align 128
80 ; Extract a value from a shufflevector..
81 define i32 @test9(<4 x i32> %a) nounwind {
84 %b = shufflevector <4 x i32> %a, <4 x i32> undef, <8 x i32> <i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 undef, i32 4>
85 %r = extractelement <8 x i32> %b, i32 2
90 ; Extract a value which is the result of an undef mask.
91 define i32 @test10(<4 x i32> %a) nounwind {
95 %b = shufflevector <4 x i32> %a, <4 x i32> undef, <8 x i32> <i32 1, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
96 %r = extractelement <8 x i32> %b, i32 2
100 define <4 x float> @test11(<4 x float> %a) nounwind {
102 ; check: vpermilps $27
103 %tmp1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
104 ret <4 x float> %tmp1
107 define <4 x float> @test12(<4 x float>* %a) nounwind {
109 ; CHECK: vpermilps $27, (
110 %tmp0 = load <4 x float>* %a
111 %tmp1 = shufflevector <4 x float> %tmp0, <4 x float> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
112 ret <4 x float> %tmp1
115 define <4 x i32> @test13(<4 x i32> %a) nounwind {
118 %tmp1 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
122 define <4 x i32> @test14(<4 x i32>* %a) nounwind {
124 ; CHECK: vpshufd $27, (
125 %tmp0 = load <4 x i32>* %a
126 %tmp1 = shufflevector <4 x i32> %tmp0, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
133 define <4 x i32> @test15(<2 x i32>%x) nounwind readnone {
134 %x1 = shufflevector <2 x i32> %x, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
139 define <8 x float> @test16(float* nocapture %f) nounwind uwtable readonly ssp {
141 %0 = bitcast float* %f to <4 x float>*
142 %1 = load <4 x float>* %0, align 8
146 ; CHECK-NOT: vinsertf128
147 %shuffle.i = shufflevector <4 x float> %1, <4 x float> <float 0.000000e+00, float undef, float undef, float undef>, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 4, i32 4, i32 4>
148 ret <8 x float> %shuffle.i