The VPERM2F128 is a AVX instruction which permutes between two 256-bit
[oota-llvm.git] / test / CodeGen / X86 / avx-vperm2f128.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s
2
3 ; CHECK: vperm2f128 $1
4 define <8 x float> @A(<8 x float> %a, <8 x float> %b) nounwind uwtable readnone ssp {
5 entry:
6   %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3>
7   ret <8 x float> %shuffle
8 }
9
10 ; CHECK: vperm2f128 $48
11 define <8 x float> @B(<8 x float> %a, <8 x float> %b) nounwind uwtable readnone ssp {
12 entry:
13   %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>
14   ret <8 x float> %shuffle
15 }
16
17 ; CHECK: vperm2f128 $0
18 define <8 x float> @C(<8 x float> %a, <8 x float> %b) nounwind uwtable readnone ssp {
19 entry:
20   %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
21   ret <8 x float> %shuffle
22 }
23
24 ; CHECK: vperm2f128 $17
25 define <8 x float> @D(<8 x float> %a, <8 x float> %b) nounwind uwtable readnone ssp {
26 entry:
27   %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 4, i32 5, i32 6, i32 7>
28   ret <8 x float> %shuffle
29 }
30
31 ; CHECK: vperm2f128 $17
32 define <32 x i8> @E(<32 x i8> %a, <32 x i8> %b) nounwind uwtable readnone ssp {
33 entry:
34   %shuffle = shufflevector <32 x i8> %a, <32 x i8> %b, <32 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
35   ret <32 x i8> %shuffle
36 }
37
38 ; CHECK: vperm2f128 $33
39 define <4 x i64> @E2(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
40 entry:
41   %shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
42   ret <4 x i64> %shuffle
43 }
44
45 ;;;; Cases with undef indicies mixed in the mask
46
47 ; CHECK: vperm2f128 $33
48 define <8 x float> @F(<8 x float> %a, <8 x float> %b) nounwind uwtable readnone ssp {
49 entry:
50   %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 undef, i32 undef, i32 6, i32 7, i32 undef, i32 9, i32 undef, i32 11>
51   ret <8 x float> %shuffle
52 }
53
54 ;;;; Cases we must not select vperm2f128
55
56 ; CHECK: _G
57 ; CHECK-NOT: vperm2f128
58 define <8 x float> @G(<8 x float> %a, <8 x float> %b) nounwind uwtable readnone ssp {
59 entry:
60   %shuffle = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 undef, i32 undef, i32 6, i32 7, i32 undef, i32 12, i32 undef, i32 15>
61   ret <8 x float> %shuffle
62 }