Fixed a bug in LowerVECTOR_SHUFFLE caused assertion failure
[oota-llvm.git] / test / CodeGen / X86 / avx-shuffle.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s
2
3 ; PR11102
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>
6   ret <4 x float> %b
7 ; CHECK: test1:
8 ; CHECK: vshufps
9 ; CHECK: vpshufd
10 }
11
12 ; rdar://10538417
13 define <3 x i64> @test2(<2 x i64> %v) nounwind readnone {
14 ; CHECK: test2:
15 ; CHECK: vxorpd
16 ; CHECK: vperm2f128
17   %1 = shufflevector <2 x i64> %v, <2 x i64> %v, <3 x i32> <i32 0, i32 1, i32 undef>
18   %2 = shufflevector <3 x i64> zeroinitializer, <3 x i64> %1, <3 x i32> <i32 3, i32 4, i32 2>
19   ret <3 x i64> %2
20 }
21
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>
24   ret <4 x i64> %c
25 ; CHECK: test3:
26 ; CHECK: vperm2f128
27 }
28
29 define <8 x float> @test4(float %a) nounwind {
30   %b = insertelement <8 x float> zeroinitializer, float %a, i32 0
31   ret <8 x float> %b
32 ; CHECK: test4:
33 ; CHECK: vinsertf128
34 }
35
36 ; rdar://10594409
37 define <8 x float> @test5(float* nocapture %f) nounwind uwtable readonly ssp {
38 entry:
39   %0 = bitcast float* %f to <4 x float>*
40   %1 = load <4 x float>* %0, align 16
41 ; CHECK: vmovaps
42 ; CHECK-NOT: vxorps
43 ; CHECK-NOT: vinsertf128
44   %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>
45   ret <8 x float> %shuffle.i
46 }
47
48 define <4 x double> @test6(double* nocapture %d) nounwind uwtable readonly ssp {
49 entry:
50   %0 = bitcast double* %d to <2 x double>*
51   %1 = load <2 x double>* %0, align 16
52 ; CHECK: vmovaps
53 ; CHECK-NOT: vxorps
54 ; CHECK-NOT: vinsertf128
55   %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>
56   ret <4 x double> %shuffle.i
57 }
58
59 define <16 x i16> @test7(<4 x i16> %a) nounwind {
60 ; CHECK: test7
61
62   %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>
63   ret <16 x i16> %b
64 }
65