[X86] Add a check for 'isMOVHLPSMask' within method 'isShuffleMaskLegal'.
[oota-llvm.git] / test / CodeGen / X86 / combine-vec-shuffle-4.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s
2
3 ; Verify that we fold shuffles according to rule:
4 ;  (shuffle(shuffle A, Undef, M0), B, M1) -> (shuffle A, B, M2)
5
6 define <4 x float> @test1(<4 x float> %a, <4 x float> %b) {
7   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
8   %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 4, i32 5, i32 1, i32 2>
9   ret <4 x float> %2
10 }
11 ; CHECK-LABEL: test1
12 ; Mask: [4,5,2,3]
13 ; CHECK: movsd
14 ; CHECK: ret
15
16 define <4 x float> @test2(<4 x float> %a, <4 x float> %b) {
17   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
18   %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
19   ret <4 x float> %2
20 }
21 ; CHECK-LABEL: test2
22 ; Mask: [0,1,4,5]
23 ; CHECK: movlhps 
24 ; CHECK: ret
25
26 define <4 x float> @test3(<4 x float> %a, <4 x float> %b) {
27   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
28   %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
29   ret <4 x float> %2
30 }
31 ; CHECK-LABEL: test3
32 ; Mask: [0,1,4,u]
33 ; CHECK: movlhps
34 ; CHECK: ret
35
36 define <4 x float> @test4(<4 x float> %a, <4 x float> %b) {
37   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
38   %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
39   ret <4 x float> %2
40 }
41 ; CHECK-LABEL: test4
42 ; Mask: [6,7,2,3]
43 ; CHECK: movhlps
44 ; CHECK-NEXT: ret
45
46 define <4 x float> @test5(<4 x float> %a, <4 x float> %b) {
47   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
48   %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 6, i32 7>
49   ret <4 x float> %2
50 }
51 ; CHECK-LABEL: test5
52 ; Mask: [0,1,6,7]
53 ; CHECK: blendps $12
54 ; CHECK: ret
55
56 ; Verify that we fold shuffles according to rule:
57 ;  (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
58
59 define <4 x float> @test6(<4 x float> %a) {
60   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
61   %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 4, i32 5, i32 1, i32 2>
62   ret <4 x float> %2
63 }
64 ; CHECK-LABEL: test6
65 ; Mask: [0,1,2,3]
66 ; CHECK-NOT: pshufd
67 ; CHECK-NOT: shufps
68 ; CHECK-NOT: movlhps
69 ; CHECK: ret
70
71 define <4 x float> @test7(<4 x float> %a) {
72   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
73   %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
74   ret <4 x float> %2
75 }
76 ; CHECK-LABEL: test7
77 ; Mask: [0,1,0,1]
78 ; CHECK-NOT: pshufd
79 ; CHECK-NOT: shufps
80 ; CHECK: movlhps 
81 ; CHECK-NEXT: ret
82
83 define <4 x float> @test8(<4 x float> %a) {
84   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
85   %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
86   ret <4 x float> %2
87 }
88 ; CHECK-LABEL: test8
89 ; Mask: [0,1,0,u]
90 ; CHECK-NOT: pshufd
91 ; CHECK-NOT: shufps
92 ; CHECK: movlhps
93 ; CHECK-NEXT: ret
94
95 define <4 x float> @test9(<4 x float> %a) {
96   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
97   %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
98   ret <4 x float> %2
99 }
100 ; CHECK-LABEL: test9
101 ; Mask: [2,3,2,3]
102 ; CHECK-NOT: movlhps
103 ; CHECK-NOT: palignr
104 ; CHECK: movhlps
105 ; CHECK-NEXT: ret
106
107 define <4 x float> @test10(<4 x float> %a) {
108   %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
109   %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 2, i32 6, i32 7>
110   ret <4 x float> %2
111 }
112 ; CHECK-LABEL: test10
113 ; Mask: [0,1,2,3]
114 ; CHECK-NOT: pshufd
115 ; CHECK-NOT: shufps
116 ; CHECK-NOT: movlhps
117 ; CHECK: ret
118