Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mcpu=x86-64 -mattr=+sse2 | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE2 |
| 2 | ; RUN: llc < %s -mcpu=x86-64 -mattr=+ssse3 | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSSE3 |
| 3 | ; RUN: llc < %s -mcpu=x86-64 -mattr=+sse4.1 | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE41 |
| 4 | ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX1 |
| 5 | ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx2 | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX2 |
Chandler Carruth | 7b27067 | 2014-10-02 07:13:25 +0000 | [diff] [blame] | 6 | ; |
| 7 | ; Verify that the DAG combiner correctly folds bitwise operations across |
| 8 | ; shuffles, nested shuffles with undef, pairs of nested shuffles, and other |
| 9 | ; basic and always-safe patterns. Also test that the DAG combiner will combine |
| 10 | ; target-specific shuffle instructions where reasonable. |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 11 | |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 12 | target triple = "x86_64-unknown-unknown" |
| 13 | |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 14 | declare <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32>, i8) |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 15 | declare <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16>, i8) |
| 16 | declare <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16>, i8) |
| 17 | |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 18 | define <4 x i32> @combine_pshufd1(<4 x i32> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 19 | ; ALL-LABEL: combine_pshufd1: |
| 20 | ; ALL: # BB#0: # %entry |
| 21 | ; ALL-NEXT: retq |
| 22 | entry: |
| 23 | %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 27) |
| 24 | %c = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %b, i8 27) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 25 | ret <4 x i32> %c |
| 26 | } |
| 27 | |
| 28 | define <4 x i32> @combine_pshufd2(<4 x i32> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 29 | ; ALL-LABEL: combine_pshufd2: |
| 30 | ; ALL: # BB#0: # %entry |
| 31 | ; ALL-NEXT: retq |
| 32 | entry: |
| 33 | %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 27) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 34 | %b.cast = bitcast <4 x i32> %b to <8 x i16> |
| 35 | %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b.cast, i8 -28) |
| 36 | %c.cast = bitcast <8 x i16> %c to <4 x i32> |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 37 | %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 27) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 38 | ret <4 x i32> %d |
| 39 | } |
| 40 | |
| 41 | define <4 x i32> @combine_pshufd3(<4 x i32> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 42 | ; ALL-LABEL: combine_pshufd3: |
| 43 | ; ALL: # BB#0: # %entry |
| 44 | ; ALL-NEXT: retq |
| 45 | entry: |
| 46 | %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 27) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 47 | %b.cast = bitcast <4 x i32> %b to <8 x i16> |
| 48 | %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b.cast, i8 -28) |
| 49 | %c.cast = bitcast <8 x i16> %c to <4 x i32> |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 50 | %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 27) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 51 | ret <4 x i32> %d |
| 52 | } |
| 53 | |
| 54 | define <4 x i32> @combine_pshufd4(<4 x i32> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 55 | ; SSE-LABEL: combine_pshufd4: |
| 56 | ; SSE: # BB#0: # %entry |
| 57 | ; SSE-NEXT: pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4] |
| 58 | ; SSE-NEXT: retq |
| 59 | ; |
| 60 | ; AVX-LABEL: combine_pshufd4: |
| 61 | ; AVX: # BB#0: # %entry |
| 62 | ; AVX-NEXT: vpshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4] |
| 63 | ; AVX-NEXT: retq |
| 64 | entry: |
| 65 | %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 -31) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 66 | %b.cast = bitcast <4 x i32> %b to <8 x i16> |
| 67 | %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b.cast, i8 27) |
| 68 | %c.cast = bitcast <8 x i16> %c to <4 x i32> |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 69 | %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 -31) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 70 | ret <4 x i32> %d |
| 71 | } |
| 72 | |
| 73 | define <4 x i32> @combine_pshufd5(<4 x i32> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 74 | ; SSE-LABEL: combine_pshufd5: |
| 75 | ; SSE: # BB#0: # %entry |
| 76 | ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7] |
| 77 | ; SSE-NEXT: retq |
| 78 | ; |
| 79 | ; AVX-LABEL: combine_pshufd5: |
| 80 | ; AVX: # BB#0: # %entry |
| 81 | ; AVX-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7] |
| 82 | ; AVX-NEXT: retq |
| 83 | entry: |
| 84 | %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 -76) |
Chandler Carruth | 688001f | 2014-06-27 11:40:13 +0000 | [diff] [blame] | 85 | %b.cast = bitcast <4 x i32> %b to <8 x i16> |
| 86 | %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b.cast, i8 27) |
| 87 | %c.cast = bitcast <8 x i16> %c to <4 x i32> |
| 88 | %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 -76) |
| 89 | ret <4 x i32> %d |
| 90 | } |
| 91 | |
Benjamin Kramer | e739cf3 | 2014-07-02 15:09:44 +0000 | [diff] [blame] | 92 | define <4 x i32> @combine_pshufd6(<4 x i32> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 93 | ; SSE-LABEL: combine_pshufd6: |
| 94 | ; SSE: # BB#0: # %entry |
| 95 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,0,0,0] |
| 96 | ; SSE-NEXT: retq |
| 97 | ; |
| 98 | ; AVX-LABEL: combine_pshufd6: |
| 99 | ; AVX: # BB#0: # %entry |
| 100 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,0] |
| 101 | ; AVX-NEXT: retq |
| 102 | entry: |
Benjamin Kramer | e739cf3 | 2014-07-02 15:09:44 +0000 | [diff] [blame] | 103 | %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 0) |
| 104 | %c = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %b, i8 8) |
| 105 | ret <4 x i32> %c |
| 106 | } |
| 107 | |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 108 | define <8 x i16> @combine_pshuflw1(<8 x i16> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 109 | ; ALL-LABEL: combine_pshuflw1: |
| 110 | ; ALL: # BB#0: # %entry |
| 111 | ; ALL-NEXT: retq |
| 112 | entry: |
| 113 | %b = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %a, i8 27) |
| 114 | %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b, i8 27) |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 115 | ret <8 x i16> %c |
| 116 | } |
| 117 | |
| 118 | define <8 x i16> @combine_pshuflw2(<8 x i16> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 119 | ; ALL-LABEL: combine_pshuflw2: |
| 120 | ; ALL: # BB#0: # %entry |
| 121 | ; ALL-NEXT: retq |
| 122 | entry: |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 123 | %b = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %a, i8 27) |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 124 | %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b, i8 -28) |
| 125 | %d = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %c, i8 27) |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 126 | ret <8 x i16> %d |
| 127 | } |
| 128 | |
| 129 | define <8 x i16> @combine_pshuflw3(<8 x i16> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 130 | ; SSE-LABEL: combine_pshuflw3: |
| 131 | ; SSE: # BB#0: # %entry |
| 132 | ; SSE-NEXT: pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4] |
| 133 | ; SSE-NEXT: retq |
| 134 | ; |
| 135 | ; AVX-LABEL: combine_pshuflw3: |
| 136 | ; AVX: # BB#0: # %entry |
| 137 | ; AVX-NEXT: vpshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4] |
| 138 | ; AVX-NEXT: retq |
| 139 | entry: |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 140 | %b = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %a, i8 27) |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 141 | %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b, i8 27) |
| 142 | %d = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %c, i8 27) |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 143 | ret <8 x i16> %d |
| 144 | } |
| 145 | |
| 146 | define <8 x i16> @combine_pshufhw1(<8 x i16> %a) { |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 147 | ; SSE-LABEL: combine_pshufhw1: |
| 148 | ; SSE: # BB#0: # %entry |
| 149 | ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7] |
| 150 | ; SSE-NEXT: retq |
| 151 | ; |
| 152 | ; AVX-LABEL: combine_pshufhw1: |
| 153 | ; AVX: # BB#0: # %entry |
| 154 | ; AVX-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7] |
| 155 | ; AVX-NEXT: retq |
| 156 | entry: |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 157 | %b = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %a, i8 27) |
Chandler Carruth | 3c7bf04 | 2014-10-02 07:22:26 +0000 | [diff] [blame] | 158 | %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b, i8 27) |
| 159 | %d = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %c, i8 27) |
Chandler Carruth | 0d6d1f2 | 2014-06-27 11:34:40 +0000 | [diff] [blame] | 160 | ret <8 x i16> %d |
| 161 | } |
Chandler Carruth | 2110501 | 2014-10-02 07:30:24 +0000 | [diff] [blame] | 162 | |
| 163 | define <4 x i32> @combine_bitwise_ops_test1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 164 | ; SSE-LABEL: combine_bitwise_ops_test1: |
| 165 | ; SSE: # BB#0: |
| 166 | ; SSE-NEXT: pand %xmm1, %xmm0 |
| 167 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 168 | ; SSE-NEXT: retq |
| 169 | ; |
| 170 | ; AVX-LABEL: combine_bitwise_ops_test1: |
| 171 | ; AVX: # BB#0: |
| 172 | ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0 |
| 173 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 174 | ; AVX-NEXT: retq |
| 175 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3> |
| 176 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3> |
| 177 | %and = and <4 x i32> %shuf1, %shuf2 |
| 178 | ret <4 x i32> %and |
| 179 | } |
| 180 | |
| 181 | define <4 x i32> @combine_bitwise_ops_test2(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 182 | ; SSE-LABEL: combine_bitwise_ops_test2: |
| 183 | ; SSE: # BB#0: |
| 184 | ; SSE-NEXT: por %xmm1, %xmm0 |
| 185 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 186 | ; SSE-NEXT: retq |
| 187 | ; |
| 188 | ; AVX-LABEL: combine_bitwise_ops_test2: |
| 189 | ; AVX: # BB#0: |
| 190 | ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0 |
| 191 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 192 | ; AVX-NEXT: retq |
| 193 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3> |
| 194 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3> |
| 195 | %or = or <4 x i32> %shuf1, %shuf2 |
| 196 | ret <4 x i32> %or |
| 197 | } |
| 198 | |
| 199 | define <4 x i32> @combine_bitwise_ops_test3(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 200 | ; SSE-LABEL: combine_bitwise_ops_test3: |
| 201 | ; SSE: # BB#0: |
| 202 | ; SSE-NEXT: pxor %xmm1, %xmm0 |
| 203 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 204 | ; SSE-NEXT: retq |
| 205 | ; |
| 206 | ; AVX-LABEL: combine_bitwise_ops_test3: |
| 207 | ; AVX: # BB#0: |
| 208 | ; AVX-NEXT: vpxor %xmm1, %xmm0, %xmm0 |
| 209 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 210 | ; AVX-NEXT: retq |
| 211 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3> |
| 212 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3> |
| 213 | %xor = xor <4 x i32> %shuf1, %shuf2 |
| 214 | ret <4 x i32> %xor |
| 215 | } |
| 216 | |
| 217 | define <4 x i32> @combine_bitwise_ops_test4(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 218 | ; SSE-LABEL: combine_bitwise_ops_test4: |
| 219 | ; SSE: # BB#0: |
| 220 | ; SSE-NEXT: pand %xmm1, %xmm0 |
| 221 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 222 | ; SSE-NEXT: retq |
| 223 | ; |
| 224 | ; AVX-LABEL: combine_bitwise_ops_test4: |
| 225 | ; AVX: # BB#0: |
| 226 | ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0 |
| 227 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 228 | ; AVX-NEXT: retq |
| 229 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 4, i32 6, i32 5, i32 7> |
| 230 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 4, i32 6, i32 5, i32 7> |
| 231 | %and = and <4 x i32> %shuf1, %shuf2 |
| 232 | ret <4 x i32> %and |
| 233 | } |
| 234 | |
| 235 | define <4 x i32> @combine_bitwise_ops_test5(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 236 | ; SSE-LABEL: combine_bitwise_ops_test5: |
| 237 | ; SSE: # BB#0: |
| 238 | ; SSE-NEXT: por %xmm1, %xmm0 |
| 239 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 240 | ; SSE-NEXT: retq |
| 241 | ; |
| 242 | ; AVX-LABEL: combine_bitwise_ops_test5: |
| 243 | ; AVX: # BB#0: |
| 244 | ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0 |
| 245 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 246 | ; AVX-NEXT: retq |
| 247 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 4, i32 6, i32 5, i32 7> |
| 248 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 4, i32 6, i32 5, i32 7> |
| 249 | %or = or <4 x i32> %shuf1, %shuf2 |
| 250 | ret <4 x i32> %or |
| 251 | } |
| 252 | |
| 253 | define <4 x i32> @combine_bitwise_ops_test6(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 254 | ; SSE-LABEL: combine_bitwise_ops_test6: |
| 255 | ; SSE: # BB#0: |
| 256 | ; SSE-NEXT: pxor %xmm1, %xmm0 |
| 257 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 258 | ; SSE-NEXT: retq |
| 259 | ; |
| 260 | ; AVX-LABEL: combine_bitwise_ops_test6: |
| 261 | ; AVX: # BB#0: |
| 262 | ; AVX-NEXT: vpxor %xmm1, %xmm0, %xmm0 |
| 263 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 264 | ; AVX-NEXT: retq |
| 265 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 4, i32 6, i32 5, i32 7> |
| 266 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 4, i32 6, i32 5, i32 7> |
| 267 | %xor = xor <4 x i32> %shuf1, %shuf2 |
| 268 | ret <4 x i32> %xor |
| 269 | } |
| 270 | |
| 271 | |
| 272 | ; Verify that DAGCombiner moves the shuffle after the xor/and/or even if shuffles |
| 273 | ; are not performing a swizzle operations. |
| 274 | |
| 275 | define <4 x i32> @combine_bitwise_ops_test1b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 276 | ; SSE2-LABEL: combine_bitwise_ops_test1b: |
| 277 | ; SSE2: # BB#0: |
| 278 | ; SSE2-NEXT: andps %xmm1, %xmm0 |
| 279 | ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 280 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 281 | ; SSE2-NEXT: retq |
| 282 | ; |
| 283 | ; SSSE3-LABEL: combine_bitwise_ops_test1b: |
| 284 | ; SSSE3: # BB#0: |
| 285 | ; SSSE3-NEXT: andps %xmm1, %xmm0 |
| 286 | ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 287 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 288 | ; SSSE3-NEXT: retq |
| 289 | ; |
| 290 | ; SSE41-LABEL: combine_bitwise_ops_test1b: |
| 291 | ; SSE41: # BB#0: |
| 292 | ; SSE41-NEXT: andps %xmm1, %xmm0 |
| 293 | ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3] |
| 294 | ; SSE41-NEXT: retq |
| 295 | ; |
| 296 | ; AVX1-LABEL: combine_bitwise_ops_test1b: |
| 297 | ; AVX1: # BB#0: |
| 298 | ; AVX1-NEXT: vandps %xmm1, %xmm0, %xmm0 |
| 299 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3] |
| 300 | ; AVX1-NEXT: retq |
| 301 | ; |
| 302 | ; AVX2-LABEL: combine_bitwise_ops_test1b: |
| 303 | ; AVX2: # BB#0: |
| 304 | ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0 |
| 305 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3] |
| 306 | ; AVX2-NEXT: retq |
| 307 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 308 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 309 | %and = and <4 x i32> %shuf1, %shuf2 |
| 310 | ret <4 x i32> %and |
| 311 | } |
| 312 | |
| 313 | define <4 x i32> @combine_bitwise_ops_test2b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 314 | ; SSE2-LABEL: combine_bitwise_ops_test2b: |
| 315 | ; SSE2: # BB#0: |
| 316 | ; SSE2-NEXT: orps %xmm1, %xmm0 |
| 317 | ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 318 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 319 | ; SSE2-NEXT: retq |
| 320 | ; |
| 321 | ; SSSE3-LABEL: combine_bitwise_ops_test2b: |
| 322 | ; SSSE3: # BB#0: |
| 323 | ; SSSE3-NEXT: orps %xmm1, %xmm0 |
| 324 | ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 325 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 326 | ; SSSE3-NEXT: retq |
| 327 | ; |
| 328 | ; SSE41-LABEL: combine_bitwise_ops_test2b: |
| 329 | ; SSE41: # BB#0: |
| 330 | ; SSE41-NEXT: orps %xmm1, %xmm0 |
| 331 | ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3] |
| 332 | ; SSE41-NEXT: retq |
| 333 | ; |
| 334 | ; AVX1-LABEL: combine_bitwise_ops_test2b: |
| 335 | ; AVX1: # BB#0: |
| 336 | ; AVX1-NEXT: vorps %xmm1, %xmm0, %xmm0 |
| 337 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3] |
| 338 | ; AVX1-NEXT: retq |
| 339 | ; |
| 340 | ; AVX2-LABEL: combine_bitwise_ops_test2b: |
| 341 | ; AVX2: # BB#0: |
| 342 | ; AVX2-NEXT: vpor %xmm1, %xmm0, %xmm0 |
| 343 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3] |
| 344 | ; AVX2-NEXT: retq |
| 345 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 346 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 347 | %or = or <4 x i32> %shuf1, %shuf2 |
| 348 | ret <4 x i32> %or |
| 349 | } |
| 350 | |
| 351 | define <4 x i32> @combine_bitwise_ops_test3b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 352 | ; SSE2-LABEL: combine_bitwise_ops_test3b: |
| 353 | ; SSE2: # BB#0: |
| 354 | ; SSE2-NEXT: xorps %xmm1, %xmm0 |
| 355 | ; SSE2-NEXT: xorps %xmm1, %xmm1 |
| 356 | ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3] |
| 357 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 358 | ; SSE2-NEXT: retq |
| 359 | ; |
| 360 | ; SSSE3-LABEL: combine_bitwise_ops_test3b: |
| 361 | ; SSSE3: # BB#0: |
| 362 | ; SSSE3-NEXT: xorps %xmm1, %xmm0 |
| 363 | ; SSSE3-NEXT: xorps %xmm1, %xmm1 |
| 364 | ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3] |
| 365 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] |
| 366 | ; SSSE3-NEXT: retq |
| 367 | ; |
| 368 | ; SSE41-LABEL: combine_bitwise_ops_test3b: |
| 369 | ; SSE41: # BB#0: |
| 370 | ; SSE41-NEXT: xorps %xmm1, %xmm0 |
| 371 | ; SSE41-NEXT: xorps %xmm1, %xmm1 |
| 372 | ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] |
| 373 | ; SSE41-NEXT: retq |
| 374 | ; |
| 375 | ; AVX1-LABEL: combine_bitwise_ops_test3b: |
| 376 | ; AVX1: # BB#0: |
| 377 | ; AVX1-NEXT: vxorps %xmm1, %xmm0, %xmm0 |
| 378 | ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 |
| 379 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] |
| 380 | ; AVX1-NEXT: retq |
| 381 | ; |
| 382 | ; AVX2-LABEL: combine_bitwise_ops_test3b: |
| 383 | ; AVX2: # BB#0: |
| 384 | ; AVX2-NEXT: vpxor %xmm1, %xmm0, %xmm0 |
| 385 | ; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1 |
| 386 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] |
| 387 | ; AVX2-NEXT: retq |
| 388 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 389 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 390 | %xor = xor <4 x i32> %shuf1, %shuf2 |
| 391 | ret <4 x i32> %xor |
| 392 | } |
| 393 | |
| 394 | define <4 x i32> @combine_bitwise_ops_test4b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 395 | ; SSE2-LABEL: combine_bitwise_ops_test4b: |
| 396 | ; SSE2: # BB#0: |
| 397 | ; SSE2-NEXT: andps %xmm1, %xmm0 |
| 398 | ; SSE2-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3] |
| 399 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,1,3] |
| 400 | ; SSE2-NEXT: retq |
| 401 | ; |
| 402 | ; SSSE3-LABEL: combine_bitwise_ops_test4b: |
| 403 | ; SSSE3: # BB#0: |
| 404 | ; SSSE3-NEXT: andps %xmm1, %xmm0 |
| 405 | ; SSSE3-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3] |
| 406 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,1,3] |
| 407 | ; SSSE3-NEXT: retq |
| 408 | ; |
| 409 | ; SSE41-LABEL: combine_bitwise_ops_test4b: |
| 410 | ; SSE41: # BB#0: |
| 411 | ; SSE41-NEXT: andps %xmm1, %xmm0 |
| 412 | ; SSE41-NEXT: blendps {{.*#+}} xmm2 = xmm2[0],xmm0[1],xmm2[2],xmm0[3] |
| 413 | ; SSE41-NEXT: movaps %xmm2, %xmm0 |
| 414 | ; SSE41-NEXT: retq |
| 415 | ; |
| 416 | ; AVX1-LABEL: combine_bitwise_ops_test4b: |
| 417 | ; AVX1: # BB#0: |
| 418 | ; AVX1-NEXT: vandps %xmm1, %xmm0, %xmm0 |
| 419 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3] |
| 420 | ; AVX1-NEXT: retq |
| 421 | ; |
| 422 | ; AVX2-LABEL: combine_bitwise_ops_test4b: |
| 423 | ; AVX2: # BB#0: |
| 424 | ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0 |
| 425 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3] |
| 426 | ; AVX2-NEXT: retq |
| 427 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 428 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 429 | %and = and <4 x i32> %shuf1, %shuf2 |
| 430 | ret <4 x i32> %and |
| 431 | } |
| 432 | |
| 433 | define <4 x i32> @combine_bitwise_ops_test5b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 434 | ; SSE2-LABEL: combine_bitwise_ops_test5b: |
| 435 | ; SSE2: # BB#0: |
| 436 | ; SSE2-NEXT: orps %xmm1, %xmm0 |
| 437 | ; SSE2-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3] |
| 438 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,1,3] |
| 439 | ; SSE2-NEXT: retq |
| 440 | ; |
| 441 | ; SSSE3-LABEL: combine_bitwise_ops_test5b: |
| 442 | ; SSSE3: # BB#0: |
| 443 | ; SSSE3-NEXT: orps %xmm1, %xmm0 |
| 444 | ; SSSE3-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3] |
| 445 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,1,3] |
| 446 | ; SSSE3-NEXT: retq |
| 447 | ; |
| 448 | ; SSE41-LABEL: combine_bitwise_ops_test5b: |
| 449 | ; SSE41: # BB#0: |
| 450 | ; SSE41-NEXT: orps %xmm1, %xmm0 |
| 451 | ; SSE41-NEXT: blendps {{.*#+}} xmm2 = xmm2[0],xmm0[1],xmm2[2],xmm0[3] |
| 452 | ; SSE41-NEXT: movaps %xmm2, %xmm0 |
| 453 | ; SSE41-NEXT: retq |
| 454 | ; |
| 455 | ; AVX1-LABEL: combine_bitwise_ops_test5b: |
| 456 | ; AVX1: # BB#0: |
| 457 | ; AVX1-NEXT: vorps %xmm1, %xmm0, %xmm0 |
| 458 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3] |
| 459 | ; AVX1-NEXT: retq |
| 460 | ; |
| 461 | ; AVX2-LABEL: combine_bitwise_ops_test5b: |
| 462 | ; AVX2: # BB#0: |
| 463 | ; AVX2-NEXT: vpor %xmm1, %xmm0, %xmm0 |
| 464 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3] |
| 465 | ; AVX2-NEXT: retq |
| 466 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 467 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 468 | %or = or <4 x i32> %shuf1, %shuf2 |
| 469 | ret <4 x i32> %or |
| 470 | } |
| 471 | |
| 472 | define <4 x i32> @combine_bitwise_ops_test6b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 473 | ; SSE2-LABEL: combine_bitwise_ops_test6b: |
| 474 | ; SSE2: # BB#0: |
| 475 | ; SSE2-NEXT: xorps %xmm1, %xmm0 |
| 476 | ; SSE2-NEXT: xorps %xmm1, %xmm1 |
| 477 | ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[1,3] |
| 478 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,2,1,3] |
| 479 | ; SSE2-NEXT: retq |
| 480 | ; |
| 481 | ; SSSE3-LABEL: combine_bitwise_ops_test6b: |
| 482 | ; SSSE3: # BB#0: |
| 483 | ; SSSE3-NEXT: xorps %xmm1, %xmm0 |
| 484 | ; SSSE3-NEXT: xorps %xmm1, %xmm1 |
| 485 | ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[1,3] |
| 486 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,2,1,3] |
| 487 | ; SSSE3-NEXT: retq |
| 488 | ; |
| 489 | ; SSE41-LABEL: combine_bitwise_ops_test6b: |
| 490 | ; SSE41: # BB#0: |
| 491 | ; SSE41-NEXT: xorps %xmm1, %xmm0 |
| 492 | ; SSE41-NEXT: xorps %xmm1, %xmm1 |
| 493 | ; SSE41-NEXT: blendps {{.*#+}} xmm1 = xmm1[0],xmm0[1],xmm1[2],xmm0[3] |
| 494 | ; SSE41-NEXT: movaps %xmm1, %xmm0 |
| 495 | ; SSE41-NEXT: retq |
| 496 | ; |
| 497 | ; AVX1-LABEL: combine_bitwise_ops_test6b: |
| 498 | ; AVX1: # BB#0: |
| 499 | ; AVX1-NEXT: vxorps %xmm1, %xmm0, %xmm0 |
| 500 | ; AVX1-NEXT: vxorps %xmm1, %xmm1, %xmm1 |
| 501 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3] |
| 502 | ; AVX1-NEXT: retq |
| 503 | ; |
| 504 | ; AVX2-LABEL: combine_bitwise_ops_test6b: |
| 505 | ; AVX2: # BB#0: |
| 506 | ; AVX2-NEXT: vpxor %xmm1, %xmm0, %xmm0 |
| 507 | ; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1 |
| 508 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3] |
| 509 | ; AVX2-NEXT: retq |
| 510 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 511 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 5, i32 2, i32 7> |
| 512 | %xor = xor <4 x i32> %shuf1, %shuf2 |
| 513 | ret <4 x i32> %xor |
| 514 | } |
| 515 | |
| 516 | define <4 x i32> @combine_bitwise_ops_test1c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 517 | ; SSE-LABEL: combine_bitwise_ops_test1c: |
| 518 | ; SSE: # BB#0: |
| 519 | ; SSE-NEXT: andps %xmm1, %xmm0 |
| 520 | ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 521 | ; SSE-NEXT: retq |
| 522 | ; |
| 523 | ; AVX-LABEL: combine_bitwise_ops_test1c: |
| 524 | ; AVX: # BB#0: |
| 525 | ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0 |
| 526 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 527 | ; AVX-NEXT: retq |
| 528 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 529 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 530 | %and = and <4 x i32> %shuf1, %shuf2 |
| 531 | ret <4 x i32> %and |
| 532 | } |
| 533 | |
| 534 | define <4 x i32> @combine_bitwise_ops_test2c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 535 | ; SSE-LABEL: combine_bitwise_ops_test2c: |
| 536 | ; SSE: # BB#0: |
| 537 | ; SSE-NEXT: orps %xmm1, %xmm0 |
| 538 | ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 539 | ; SSE-NEXT: retq |
| 540 | ; |
| 541 | ; AVX-LABEL: combine_bitwise_ops_test2c: |
| 542 | ; AVX: # BB#0: |
| 543 | ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0 |
| 544 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3] |
| 545 | ; AVX-NEXT: retq |
| 546 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 547 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 548 | %or = or <4 x i32> %shuf1, %shuf2 |
| 549 | ret <4 x i32> %or |
| 550 | } |
| 551 | |
| 552 | define <4 x i32> @combine_bitwise_ops_test3c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 553 | ; SSE-LABEL: combine_bitwise_ops_test3c: |
| 554 | ; SSE: # BB#0: |
| 555 | ; SSE-NEXT: xorps %xmm1, %xmm0 |
| 556 | ; SSE-NEXT: xorps %xmm1, %xmm1 |
| 557 | ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3] |
| 558 | ; SSE-NEXT: retq |
| 559 | ; |
| 560 | ; AVX-LABEL: combine_bitwise_ops_test3c: |
| 561 | ; AVX: # BB#0: |
| 562 | ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0 |
| 563 | ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1 |
| 564 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3] |
| 565 | ; AVX-NEXT: retq |
| 566 | %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 567 | %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 568 | %xor = xor <4 x i32> %shuf1, %shuf2 |
| 569 | ret <4 x i32> %xor |
| 570 | } |
| 571 | |
| 572 | define <4 x i32> @combine_bitwise_ops_test4c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 573 | ; SSE-LABEL: combine_bitwise_ops_test4c: |
| 574 | ; SSE: # BB#0: |
| 575 | ; SSE-NEXT: andps %xmm1, %xmm0 |
| 576 | ; SSE-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3] |
| 577 | ; SSE-NEXT: movaps %xmm2, %xmm0 |
| 578 | ; SSE-NEXT: retq |
| 579 | ; |
| 580 | ; AVX-LABEL: combine_bitwise_ops_test4c: |
| 581 | ; AVX: # BB#0: |
| 582 | ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0 |
| 583 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm2[0,2],xmm0[1,3] |
| 584 | ; AVX-NEXT: retq |
| 585 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 586 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 587 | %and = and <4 x i32> %shuf1, %shuf2 |
| 588 | ret <4 x i32> %and |
| 589 | } |
| 590 | |
| 591 | define <4 x i32> @combine_bitwise_ops_test5c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 592 | ; SSE-LABEL: combine_bitwise_ops_test5c: |
| 593 | ; SSE: # BB#0: |
| 594 | ; SSE-NEXT: orps %xmm1, %xmm0 |
| 595 | ; SSE-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3] |
| 596 | ; SSE-NEXT: movaps %xmm2, %xmm0 |
| 597 | ; SSE-NEXT: retq |
| 598 | ; |
| 599 | ; AVX-LABEL: combine_bitwise_ops_test5c: |
| 600 | ; AVX: # BB#0: |
| 601 | ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0 |
| 602 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm2[0,2],xmm0[1,3] |
| 603 | ; AVX-NEXT: retq |
| 604 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 605 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 606 | %or = or <4 x i32> %shuf1, %shuf2 |
| 607 | ret <4 x i32> %or |
| 608 | } |
| 609 | |
| 610 | define <4 x i32> @combine_bitwise_ops_test6c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { |
| 611 | ; SSE-LABEL: combine_bitwise_ops_test6c: |
| 612 | ; SSE: # BB#0: |
| 613 | ; SSE-NEXT: xorps %xmm1, %xmm0 |
| 614 | ; SSE-NEXT: xorps %xmm1, %xmm1 |
| 615 | ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[1,3] |
| 616 | ; SSE-NEXT: movaps %xmm1, %xmm0 |
| 617 | ; SSE-NEXT: retq |
| 618 | ; |
| 619 | ; AVX-LABEL: combine_bitwise_ops_test6c: |
| 620 | ; AVX: # BB#0: |
| 621 | ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0 |
| 622 | ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1 |
| 623 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm1[0,2],xmm0[1,3] |
| 624 | ; AVX-NEXT: retq |
| 625 | %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 626 | %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 2, i32 5, i32 7> |
| 627 | %xor = xor <4 x i32> %shuf1, %shuf2 |
| 628 | ret <4 x i32> %xor |
| 629 | } |
Chandler Carruth | b2941e2 | 2014-10-02 07:42:58 +0000 | [diff] [blame^] | 630 | |
| 631 | define <4 x i32> @combine_nested_undef_test1(<4 x i32> %A, <4 x i32> %B) { |
| 632 | ; SSE-LABEL: combine_nested_undef_test1: |
| 633 | ; SSE: # BB#0: |
| 634 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,0,0,1] |
| 635 | ; SSE-NEXT: retq |
| 636 | ; |
| 637 | ; AVX-LABEL: combine_nested_undef_test1: |
| 638 | ; AVX: # BB#0: |
| 639 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[3,0,0,1] |
| 640 | ; AVX-NEXT: retq |
| 641 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 3, i32 1> |
| 642 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 3> |
| 643 | ret <4 x i32> %2 |
| 644 | } |
| 645 | |
| 646 | define <4 x i32> @combine_nested_undef_test2(<4 x i32> %A, <4 x i32> %B) { |
| 647 | ; SSE-LABEL: combine_nested_undef_test2: |
| 648 | ; SSE: # BB#0: |
| 649 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,0,0,3] |
| 650 | ; SSE-NEXT: retq |
| 651 | ; |
| 652 | ; AVX-LABEL: combine_nested_undef_test2: |
| 653 | ; AVX: # BB#0: |
| 654 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,0,0,3] |
| 655 | ; AVX-NEXT: retq |
| 656 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 3> |
| 657 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 3> |
| 658 | ret <4 x i32> %2 |
| 659 | } |
| 660 | |
| 661 | define <4 x i32> @combine_nested_undef_test3(<4 x i32> %A, <4 x i32> %B) { |
| 662 | ; SSE-LABEL: combine_nested_undef_test3: |
| 663 | ; SSE: # BB#0: |
| 664 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,0,0,3] |
| 665 | ; SSE-NEXT: retq |
| 666 | ; |
| 667 | ; AVX-LABEL: combine_nested_undef_test3: |
| 668 | ; AVX: # BB#0: |
| 669 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,0,0,3] |
| 670 | ; AVX-NEXT: retq |
| 671 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 6, i32 2, i32 3> |
| 672 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 3> |
| 673 | ret <4 x i32> %2 |
| 674 | } |
| 675 | |
| 676 | define <4 x i32> @combine_nested_undef_test4(<4 x i32> %A, <4 x i32> %B) { |
| 677 | ; SSE-LABEL: combine_nested_undef_test4: |
| 678 | ; SSE: # BB#0: |
| 679 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,0,0,1] |
| 680 | ; SSE-NEXT: retq |
| 681 | ; |
| 682 | ; AVX-LABEL: combine_nested_undef_test4: |
| 683 | ; AVX: # BB#0: |
| 684 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,1] |
| 685 | ; AVX-NEXT: retq |
| 686 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 7, i32 1> |
| 687 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 4, i32 4, i32 0, i32 3> |
| 688 | ret <4 x i32> %2 |
| 689 | } |
| 690 | |
| 691 | define <4 x i32> @combine_nested_undef_test5(<4 x i32> %A, <4 x i32> %B) { |
| 692 | ; SSE-LABEL: combine_nested_undef_test5: |
| 693 | ; SSE: # BB#0: |
| 694 | ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1] |
| 695 | ; SSE-NEXT: retq |
| 696 | ; |
| 697 | ; AVX-LABEL: combine_nested_undef_test5: |
| 698 | ; AVX: # BB#0: |
| 699 | ; AVX-NEXT: vmovhlps {{.*#+}} xmm0 = xmm0[1,1] |
| 700 | ; AVX-NEXT: retq |
| 701 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 5, i32 5, i32 2, i32 3> |
| 702 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 4, i32 3> |
| 703 | ret <4 x i32> %2 |
| 704 | } |
| 705 | |
| 706 | define <4 x i32> @combine_nested_undef_test6(<4 x i32> %A, <4 x i32> %B) { |
| 707 | ; SSE-LABEL: combine_nested_undef_test6: |
| 708 | ; SSE: # BB#0: |
| 709 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,0,0,0] |
| 710 | ; SSE-NEXT: retq |
| 711 | ; |
| 712 | ; AVX-LABEL: combine_nested_undef_test6: |
| 713 | ; AVX: # BB#0: |
| 714 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,0,0,0] |
| 715 | ; AVX-NEXT: retq |
| 716 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 6, i32 2, i32 4> |
| 717 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 4> |
| 718 | ret <4 x i32> %2 |
| 719 | } |
| 720 | |
| 721 | define <4 x i32> @combine_nested_undef_test7(<4 x i32> %A, <4 x i32> %B) { |
| 722 | ; SSE-LABEL: combine_nested_undef_test7: |
| 723 | ; SSE: # BB#0: |
| 724 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,0,2] |
| 725 | ; SSE-NEXT: retq |
| 726 | ; |
| 727 | ; AVX-LABEL: combine_nested_undef_test7: |
| 728 | ; AVX: # BB#0: |
| 729 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,0,2] |
| 730 | ; AVX-NEXT: retq |
| 731 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 7> |
| 732 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 0, i32 2> |
| 733 | ret <4 x i32> %2 |
| 734 | } |
| 735 | |
| 736 | define <4 x i32> @combine_nested_undef_test8(<4 x i32> %A, <4 x i32> %B) { |
| 737 | ; SSE-LABEL: combine_nested_undef_test8: |
| 738 | ; SSE: # BB#0: |
| 739 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,0,3,0] |
| 740 | ; SSE-NEXT: retq |
| 741 | ; |
| 742 | ; AVX-LABEL: combine_nested_undef_test8: |
| 743 | ; AVX: # BB#0: |
| 744 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,0,3,0] |
| 745 | ; AVX-NEXT: retq |
| 746 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 6, i32 3> |
| 747 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 4, i32 3, i32 4> |
| 748 | ret <4 x i32> %2 |
| 749 | } |
| 750 | |
| 751 | define <4 x i32> @combine_nested_undef_test9(<4 x i32> %A, <4 x i32> %B) { |
| 752 | ; SSE-LABEL: combine_nested_undef_test9: |
| 753 | ; SSE: # BB#0: |
| 754 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,3,0,2] |
| 755 | ; SSE-NEXT: retq |
| 756 | ; |
| 757 | ; AVX-LABEL: combine_nested_undef_test9: |
| 758 | ; AVX: # BB#0: |
| 759 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,3,0,2] |
| 760 | ; AVX-NEXT: retq |
| 761 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 3, i32 2, i32 5> |
| 762 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 4, i32 2> |
| 763 | ret <4 x i32> %2 |
| 764 | } |
| 765 | |
| 766 | define <4 x i32> @combine_nested_undef_test10(<4 x i32> %A, <4 x i32> %B) { |
| 767 | ; SSE-LABEL: combine_nested_undef_test10: |
| 768 | ; SSE: # BB#0: |
| 769 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,0,1,0] |
| 770 | ; SSE-NEXT: retq |
| 771 | ; |
| 772 | ; AVX-LABEL: combine_nested_undef_test10: |
| 773 | ; AVX: # BB#0: |
| 774 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,0,1,0] |
| 775 | ; AVX-NEXT: retq |
| 776 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 1, i32 5, i32 5> |
| 777 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 4> |
| 778 | ret <4 x i32> %2 |
| 779 | } |
| 780 | |
| 781 | define <4 x i32> @combine_nested_undef_test11(<4 x i32> %A, <4 x i32> %B) { |
| 782 | ; SSE-LABEL: combine_nested_undef_test11: |
| 783 | ; SSE: # BB#0: |
| 784 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,0,2,1] |
| 785 | ; SSE-NEXT: retq |
| 786 | ; |
| 787 | ; AVX-LABEL: combine_nested_undef_test11: |
| 788 | ; AVX: # BB#0: |
| 789 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,0,2,1] |
| 790 | ; AVX-NEXT: retq |
| 791 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 2, i32 5, i32 4> |
| 792 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 0> |
| 793 | ret <4 x i32> %2 |
| 794 | } |
| 795 | |
| 796 | define <4 x i32> @combine_nested_undef_test12(<4 x i32> %A, <4 x i32> %B) { |
| 797 | ; SSE-LABEL: combine_nested_undef_test12: |
| 798 | ; SSE: # BB#0: |
| 799 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,0,0,0] |
| 800 | ; SSE-NEXT: retq |
| 801 | ; |
| 802 | ; AVX1-LABEL: combine_nested_undef_test12: |
| 803 | ; AVX1: # BB#0: |
| 804 | ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,0] |
| 805 | ; AVX1-NEXT: retq |
| 806 | ; |
| 807 | ; AVX2-LABEL: combine_nested_undef_test12: |
| 808 | ; AVX2: # BB#0: |
| 809 | ; AVX2-NEXT: vbroadcastss %xmm0, %xmm0 |
| 810 | ; AVX2-NEXT: retq |
| 811 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 0, i32 2, i32 4> |
| 812 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 4, i32 0, i32 4> |
| 813 | ret <4 x i32> %2 |
| 814 | } |
| 815 | |
| 816 | ; The following pair of shuffles is folded into vector %A. |
| 817 | define <4 x i32> @combine_nested_undef_test13(<4 x i32> %A, <4 x i32> %B) { |
| 818 | ; ALL-LABEL: combine_nested_undef_test13: |
| 819 | ; ALL: # BB#0: |
| 820 | ; ALL-NEXT: retq |
| 821 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 4, i32 2, i32 6> |
| 822 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 4, i32 0, i32 2, i32 4> |
| 823 | ret <4 x i32> %2 |
| 824 | } |
| 825 | |
| 826 | ; The following pair of shuffles is folded into vector %B. |
| 827 | define <4 x i32> @combine_nested_undef_test14(<4 x i32> %A, <4 x i32> %B) { |
| 828 | ; SSE-LABEL: combine_nested_undef_test14: |
| 829 | ; SSE: # BB#0: |
| 830 | ; SSE-NEXT: movaps %xmm1, %xmm0 |
| 831 | ; SSE-NEXT: retq |
| 832 | ; |
| 833 | ; AVX-LABEL: combine_nested_undef_test14: |
| 834 | ; AVX: # BB#0: |
| 835 | ; AVX-NEXT: vmovaps %xmm1, %xmm0 |
| 836 | ; AVX-NEXT: retq |
| 837 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 6, i32 2, i32 4> |
| 838 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 4, i32 1, i32 4> |
| 839 | ret <4 x i32> %2 |
| 840 | } |
| 841 | |
| 842 | |
| 843 | ; Verify that we don't optimize the following cases. We expect more than one shuffle. |
| 844 | ; |
| 845 | ; FIXME: Many of these already don't make sense, and the rest should stop |
| 846 | ; making sense with th enew vector shuffle lowering. Revisit at least testing for |
| 847 | ; it. |
| 848 | |
| 849 | define <4 x i32> @combine_nested_undef_test15(<4 x i32> %A, <4 x i32> %B) { |
| 850 | ; SSE-LABEL: combine_nested_undef_test15: |
| 851 | ; SSE: # BB#0: |
| 852 | ; SSE-NEXT: movlhps {{.*#+}} xmm1 = xmm1[0],xmm0[0] |
| 853 | ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[3,1] |
| 854 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[2,1,0,3] |
| 855 | ; SSE-NEXT: retq |
| 856 | ; |
| 857 | ; AVX-LABEL: combine_nested_undef_test15: |
| 858 | ; AVX: # BB#0: |
| 859 | ; AVX-NEXT: vmovlhps {{.*#+}} xmm1 = xmm1[0],xmm0[0] |
| 860 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm1[2,0],xmm0[3,1] |
| 861 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 862 | ; AVX-NEXT: retq |
| 863 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 3, i32 1> |
| 864 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3> |
| 865 | ret <4 x i32> %2 |
| 866 | } |
| 867 | |
| 868 | define <4 x i32> @combine_nested_undef_test16(<4 x i32> %A, <4 x i32> %B) { |
| 869 | ; SSE2-LABEL: combine_nested_undef_test16: |
| 870 | ; SSE2: # BB#0: |
| 871 | ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3] |
| 872 | ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,2,0,3] |
| 873 | ; SSE2-NEXT: retq |
| 874 | ; |
| 875 | ; SSSE3-LABEL: combine_nested_undef_test16: |
| 876 | ; SSSE3: # BB#0: |
| 877 | ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3] |
| 878 | ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,2,0,3] |
| 879 | ; SSSE3-NEXT: retq |
| 880 | ; |
| 881 | ; SSE41-LABEL: combine_nested_undef_test16: |
| 882 | ; SSE41: # BB#0: |
| 883 | ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] |
| 884 | ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 885 | ; SSE41-NEXT: retq |
| 886 | ; |
| 887 | ; AVX1-LABEL: combine_nested_undef_test16: |
| 888 | ; AVX1: # BB#0: |
| 889 | ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] |
| 890 | ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 891 | ; AVX1-NEXT: retq |
| 892 | ; |
| 893 | ; AVX2-LABEL: combine_nested_undef_test16: |
| 894 | ; AVX2: # BB#0: |
| 895 | ; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] |
| 896 | ; AVX2-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 897 | ; AVX2-NEXT: retq |
| 898 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 7> |
| 899 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3> |
| 900 | ret <4 x i32> %2 |
| 901 | } |
| 902 | |
| 903 | define <4 x i32> @combine_nested_undef_test17(<4 x i32> %A, <4 x i32> %B) { |
| 904 | ; SSE-LABEL: combine_nested_undef_test17: |
| 905 | ; SSE: # BB#0: |
| 906 | ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[1,0] |
| 907 | ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[3,1] |
| 908 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[2,1,0,3] |
| 909 | ; SSE-NEXT: retq |
| 910 | ; |
| 911 | ; AVX-LABEL: combine_nested_undef_test17: |
| 912 | ; AVX: # BB#0: |
| 913 | ; AVX-NEXT: vshufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[1,0] |
| 914 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm1[0,2],xmm0[3,1] |
| 915 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 916 | ; AVX-NEXT: retq |
| 917 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 3, i32 1> |
| 918 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3> |
| 919 | ret <4 x i32> %2 |
| 920 | } |
| 921 | |
| 922 | define <4 x i32> @combine_nested_undef_test18(<4 x i32> %A, <4 x i32> %B) { |
| 923 | ; SSE-LABEL: combine_nested_undef_test18: |
| 924 | ; SSE: # BB#0: |
| 925 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,0,3] |
| 926 | ; SSE-NEXT: retq |
| 927 | ; |
| 928 | ; AVX-LABEL: combine_nested_undef_test18: |
| 929 | ; AVX: # BB#0: |
| 930 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm1[1,1,0,3] |
| 931 | ; AVX-NEXT: retq |
| 932 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 5, i32 2, i32 7> |
| 933 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 0, i32 3> |
| 934 | ret <4 x i32> %2 |
| 935 | } |
| 936 | |
| 937 | define <4 x i32> @combine_nested_undef_test19(<4 x i32> %A, <4 x i32> %B) { |
| 938 | ; SSE-LABEL: combine_nested_undef_test19: |
| 939 | ; SSE: # BB#0: |
| 940 | ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0] |
| 941 | ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,2] |
| 942 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,0,0,0] |
| 943 | ; SSE-NEXT: retq |
| 944 | ; |
| 945 | ; AVX-LABEL: combine_nested_undef_test19: |
| 946 | ; AVX: # BB#0: |
| 947 | ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0] |
| 948 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,2] |
| 949 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,0,0,0] |
| 950 | ; AVX-NEXT: retq |
| 951 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 5, i32 6> |
| 952 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 0, i32 0, i32 0> |
| 953 | ret <4 x i32> %2 |
| 954 | } |
| 955 | |
| 956 | define <4 x i32> @combine_nested_undef_test20(<4 x i32> %A, <4 x i32> %B) { |
| 957 | ; SSE-LABEL: combine_nested_undef_test20: |
| 958 | ; SSE: # BB#0: |
| 959 | ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,2],xmm1[0,0] |
| 960 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 961 | ; SSE-NEXT: retq |
| 962 | ; |
| 963 | ; AVX-LABEL: combine_nested_undef_test20: |
| 964 | ; AVX: # BB#0: |
| 965 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[3,2],xmm1[0,0] |
| 966 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,1,0,3] |
| 967 | ; AVX-NEXT: retq |
| 968 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 3, i32 2, i32 4, i32 4> |
| 969 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3> |
| 970 | ret <4 x i32> %2 |
| 971 | } |
| 972 | |
| 973 | define <4 x i32> @combine_nested_undef_test21(<4 x i32> %A, <4 x i32> %B) { |
| 974 | ; SSE-LABEL: combine_nested_undef_test21: |
| 975 | ; SSE: # BB#0: |
| 976 | ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[1,0] |
| 977 | ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[3,1] |
| 978 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,1,0,3] |
| 979 | ; SSE-NEXT: retq |
| 980 | ; |
| 981 | ; AVX-LABEL: combine_nested_undef_test21: |
| 982 | ; AVX: # BB#0: |
| 983 | ; AVX-NEXT: vshufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[1,0] |
| 984 | ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm1[0,2],xmm0[3,1] |
| 985 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,0,3] |
| 986 | ; AVX-NEXT: retq |
| 987 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 3, i32 1> |
| 988 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 3> |
| 989 | ret <4 x i32> %2 |
| 990 | } |
| 991 | |
| 992 | |
| 993 | ; Test that we correctly combine shuffles according to rule |
| 994 | ; shuffle(shuffle(x, y), undef) -> shuffle(y, undef) |
| 995 | |
| 996 | define <4 x i32> @combine_nested_undef_test22(<4 x i32> %A, <4 x i32> %B) { |
| 997 | ; SSE-LABEL: combine_nested_undef_test22: |
| 998 | ; SSE: # BB#0: |
| 999 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,1,3] |
| 1000 | ; SSE-NEXT: retq |
| 1001 | ; |
| 1002 | ; AVX-LABEL: combine_nested_undef_test22: |
| 1003 | ; AVX: # BB#0: |
| 1004 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm1[1,1,1,3] |
| 1005 | ; AVX-NEXT: retq |
| 1006 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 5, i32 2, i32 7> |
| 1007 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 3> |
| 1008 | ret <4 x i32> %2 |
| 1009 | } |
| 1010 | |
| 1011 | define <4 x i32> @combine_nested_undef_test23(<4 x i32> %A, <4 x i32> %B) { |
| 1012 | ; SSE-LABEL: combine_nested_undef_test23: |
| 1013 | ; SSE: # BB#0: |
| 1014 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,1,0,3] |
| 1015 | ; SSE-NEXT: retq |
| 1016 | ; |
| 1017 | ; AVX-LABEL: combine_nested_undef_test23: |
| 1018 | ; AVX: # BB#0: |
| 1019 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm1[0,1,0,3] |
| 1020 | ; AVX-NEXT: retq |
| 1021 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 5, i32 2, i32 7> |
| 1022 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 3> |
| 1023 | ret <4 x i32> %2 |
| 1024 | } |
| 1025 | |
| 1026 | define <4 x i32> @combine_nested_undef_test24(<4 x i32> %A, <4 x i32> %B) { |
| 1027 | ; SSE-LABEL: combine_nested_undef_test24: |
| 1028 | ; SSE: # BB#0: |
| 1029 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,3,2,0] |
| 1030 | ; SSE-NEXT: retq |
| 1031 | ; |
| 1032 | ; AVX-LABEL: combine_nested_undef_test24: |
| 1033 | ; AVX: # BB#0: |
| 1034 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm1[0,3,2,0] |
| 1035 | ; AVX-NEXT: retq |
| 1036 | %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 6, i32 7> |
| 1037 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 3, i32 2, i32 4> |
| 1038 | ret <4 x i32> %2 |
| 1039 | } |
| 1040 | |
| 1041 | define <4 x i32> @combine_nested_undef_test25(<4 x i32> %A, <4 x i32> %B) { |
| 1042 | ; SSE-LABEL: combine_nested_undef_test25: |
| 1043 | ; SSE: # BB#0: |
| 1044 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1] |
| 1045 | ; SSE-NEXT: retq |
| 1046 | ; |
| 1047 | ; AVX-LABEL: combine_nested_undef_test25: |
| 1048 | ; AVX: # BB#0: |
| 1049 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,0,1] |
| 1050 | ; AVX-NEXT: retq |
| 1051 | %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 1, i32 5, i32 2, i32 4> |
| 1052 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 1, i32 3, i32 1> |
| 1053 | ret <4 x i32> %2 |
| 1054 | } |
| 1055 | |
| 1056 | define <4 x i32> @combine_nested_undef_test26(<4 x i32> %A, <4 x i32> %B) { |
| 1057 | ; SSE-LABEL: combine_nested_undef_test26: |
| 1058 | ; SSE: # BB#0: |
| 1059 | ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1] |
| 1060 | ; SSE-NEXT: retq |
| 1061 | ; |
| 1062 | ; AVX-LABEL: combine_nested_undef_test26: |
| 1063 | ; AVX: # BB#0: |
| 1064 | ; AVX-NEXT: vmovhlps {{.*#+}} xmm0 = xmm0[1,1] |
| 1065 | ; AVX-NEXT: retq |
| 1066 | %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 1, i32 2, i32 6, i32 7> |
| 1067 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 2, i32 3> |
| 1068 | ret <4 x i32> %2 |
| 1069 | } |
| 1070 | |
| 1071 | define <4 x i32> @combine_nested_undef_test27(<4 x i32> %A, <4 x i32> %B) { |
| 1072 | ; SSE-LABEL: combine_nested_undef_test27: |
| 1073 | ; SSE: # BB#0: |
| 1074 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1] |
| 1075 | ; SSE-NEXT: retq |
| 1076 | ; |
| 1077 | ; AVX-LABEL: combine_nested_undef_test27: |
| 1078 | ; AVX: # BB#0: |
| 1079 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,0,1] |
| 1080 | ; AVX-NEXT: retq |
| 1081 | %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 2, i32 1, i32 5, i32 4> |
| 1082 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 3, i32 2> |
| 1083 | ret <4 x i32> %2 |
| 1084 | } |
| 1085 | |
| 1086 | define <4 x i32> @combine_nested_undef_test28(<4 x i32> %A, <4 x i32> %B) { |
| 1087 | ; SSE-LABEL: combine_nested_undef_test28: |
| 1088 | ; SSE: # BB#0: |
| 1089 | ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,1,0] |
| 1090 | ; SSE-NEXT: retq |
| 1091 | ; |
| 1092 | ; AVX-LABEL: combine_nested_undef_test28: |
| 1093 | ; AVX: # BB#0: |
| 1094 | ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,1,0] |
| 1095 | ; AVX-NEXT: retq |
| 1096 | %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 1, i32 2, i32 4, i32 5> |
| 1097 | %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 3, i32 2> |
| 1098 | ret <4 x i32> %2 |
| 1099 | } |