Instead of always leaving the work to the generic legalizer when
[oota-llvm.git] / test / CodeGen / X86 / avx-basic.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s
2
3 @x = common global <8 x float> zeroinitializer, align 32
4 @y = common global <4 x double> zeroinitializer, align 32
5 @z = common global <4 x float> zeroinitializer, align 16
6
7 define void @zero128() nounwind ssp {
8 entry:
9   ; CHECK: vxorps
10   ; CHECK: vmovaps
11   store <4 x float> zeroinitializer, <4 x float>* @z, align 16
12   ret void
13 }
14
15 define void @zero256() nounwind ssp {
16 entry:
17   ; CHECK: vxorps
18   ; CHECK: vmovaps
19   ; CHECK: vmovaps
20   store <8 x float> zeroinitializer, <8 x float>* @x, align 32
21   store <4 x double> zeroinitializer, <4 x double>* @y, align 32
22   ret void
23 }
24
25 ; CHECK: vpcmpeqd
26 ; CHECK: vinsertf128 $1
27 define void @ones([0 x float]* nocapture %RET, [0 x float]* nocapture %aFOO) nounwind {
28 allocas:
29   %ptr2vec615 = bitcast [0 x float]* %RET to <8 x float>*
30   store <8 x float> <float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float
31 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float
32 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000>, <8 x
33 float>* %ptr2vec615, align 32
34   ret void
35 }
36
37 ; CHECK: vpcmpeqd
38 ; CHECK: vinsertf128 $1
39 define void @ones2([0 x i32]* nocapture %RET, [0 x i32]* nocapture %aFOO) nounwind {
40 allocas:
41   %ptr2vec615 = bitcast [0 x i32]* %RET to <8 x i32>*
42   store <8 x i32> <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>, <8 x i32>* %ptr2vec615, align 32
43   ret void
44 }
45
46 ;;; Just make sure this doesn't crash
47 ; CHECK: _ISelCrash
48 define <4 x i64> @ISelCrash(<4 x i64> %a) nounwind uwtable readnone ssp {
49 entry:
50   %shuffle = shufflevector <4 x i64> %a, <4 x i64> undef, <4 x i32> <i32 2, i32 3, i32 4, i32 4>
51   ret <4 x i64> %shuffle
52 }
53
54 ;;;
55 ;;; Check that some 256-bit vectors are xformed into 128 ops
56 ; CHECK: _A
57 ; CHECK: vshufpd $1
58 ; CHECK-NEXT: vextractf128 $1
59 ; CHECK-NEXT: vshufpd $1
60 ; CHECK-NEXT: vinsertf128 $1
61 define <4 x i64> @A(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
62 entry:
63   %shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 0, i32 7, i32 6>
64   ret <4 x i64> %shuffle
65 }
66
67 ; CHECK: vpunpckhqdq
68 ; CHECK-NEXT: vextractf128  $1
69 ; CHECK-NEXT: movlhps
70 ; CHECK-NEXT: vinsertf128 $1
71 define <4 x i64> @B(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
72 entry:
73   %shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 undef, i32 undef, i32 6>
74   ret <4 x i64> %shuffle
75 }
76
77 ; CHECK: movlhps
78 ; CHECK-NEXT: vextractf128  $1
79 ; CHECK-NEXT: movlhps
80 ; CHECK-NEXT: vinsertf128 $1
81 define <4 x i64> @C(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
82 entry:
83   %shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 undef, i32 0, i32 undef, i32 6>
84   ret <4 x i64> %shuffle
85 }
86
87 ; CHECK: vpshufd $-96
88 ; CHECK: vpshufd $-6
89 ; CHECK: vinsertf128 $1
90 define <8 x i32> @D(<8 x i32> %a, <8 x i32> %b) nounwind uwtable readnone ssp {
91 entry:
92   %shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 0, i32 2, i32 2, i32 10, i32 10, i32 11, i32 11>
93   ret <8 x i32> %shuffle
94 }
95