1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefix=SSE
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2 | FileCheck %s --check-prefix=AVX
5 ; xor undef, undef --> 0 because it's not worth fighting to make that return undef?
7 define <4 x i64> @xor_insert_insert(<2 x i64> %x, <2 x i64> %y) {
8 ; SSE-LABEL: xor_insert_insert:
10 ; SSE-NEXT: xorps %xmm1, %xmm0
11 ; SSE-NEXT: xorps %xmm1, %xmm1
14 ; AVX-LABEL: xor_insert_insert:
16 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
18 %xw = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
19 %yw = shufflevector <2 x i64> %y, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
20 %r = xor <4 x i64> %xw, %yw
24 define <4 x i64> @xor_insert_insert_high_half(<2 x i64> %x, <2 x i64> %y) {
25 ; SSE-LABEL: xor_insert_insert_high_half:
27 ; SSE-NEXT: xorps %xmm0, %xmm1
28 ; SSE-NEXT: xorps %xmm0, %xmm0
31 ; AVX-LABEL: xor_insert_insert_high_half:
33 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
34 ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
35 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm1, %ymm0
37 %xw = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
38 %yw = shufflevector <2 x i64> %y, <2 x i64> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
39 %r = xor <4 x i64> %xw, %yw
43 ; All elements of the add are undefined:
44 ; x[0] , x[1] , x[2] , x[3], u , u , u , u
45 ; + u , u , u , u , 42 , 43 , 44 , 45
47 define <8 x i32> @add_undef_elts(<4 x i32> %x) {
48 ; SSE-LABEL: add_undef_elts:
52 ; AVX-LABEL: add_undef_elts:
55 %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
56 %bogus_bo = add <8 x i32> %extend, <i32 undef, i32 undef, i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 12>
57 %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 6, i32 0, i32 5, i32 4, i32 3, i32 2, i32 1, i32 7>
58 ret <8 x i32> %arbitrary_shuf
61 ; Verify that constant operand 0 for a sub works too.
63 define <8 x i32> @sub_undef_elts(<4 x i32> %x) {
64 ; SSE-LABEL: sub_undef_elts:
68 ; AVX-LABEL: sub_undef_elts:
71 %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
72 %bogus_bo = sub <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 42, i32 43, i32 44, i32 12>, %extend
73 %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 1, i32 0, i32 5, i32 4, i32 3, i32 2, i32 6, i32 7>
74 ret <8 x i32> %arbitrary_shuf
77 ; and undef, C --> 0, so this tests that we are tracking known zero lanes.
79 define <4 x i64> @and_undef_elts(<2 x i64> %x) {
80 ; SSE-LABEL: and_undef_elts:
82 ; SSE-NEXT: xorps %xmm0, %xmm0
83 ; SSE-NEXT: xorps %xmm1, %xmm1
86 ; AVX-LABEL: and_undef_elts:
88 ; AVX-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
89 ; AVX-NEXT: vandps {{.*}}(%rip), %ymm0, %ymm0
90 ; AVX-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[3,0,1,2]
92 %extend = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
93 %bogus_bo = and <4 x i64> %extend, <i64 undef, i64 undef, i64 42, i64 43>
94 %arbitrary_shuf = shufflevector <4 x i64> %bogus_bo, <4 x i64> undef, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
95 ret <4 x i64> %arbitrary_shuf
98 ; or undef, C --> -1, so this tests that we are tracking known all-ones lanes.
100 define <4 x i64> @or_undef_elts(<2 x i64> %x) {
101 ; SSE-LABEL: or_undef_elts:
103 ; SSE-NEXT: pcmpeqd %xmm0, %xmm0
104 ; SSE-NEXT: pcmpeqd %xmm1, %xmm1
107 ; AVX-LABEL: or_undef_elts:
109 ; AVX-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
110 ; AVX-NEXT: vorps {{.*}}(%rip), %ymm0, %ymm0
111 ; AVX-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[3,0,1,2]
113 %extend = shufflevector <2 x i64> %x, <2 x i64> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
114 %bogus_bo = or <4 x i64> %extend, <i64 undef, i64 undef, i64 42, i64 43>
115 %arbitrary_shuf = shufflevector <4 x i64> %bogus_bo, <4 x i64> undef, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
116 ret <4 x i64> %arbitrary_shuf
119 ; Verify that this isn't limited to high/low halves.
121 define <8 x i32> @xor_undef_elts(<4 x i32> %x) {
122 ; SSE-LABEL: xor_undef_elts:
126 ; AVX-LABEL: xor_undef_elts:
129 %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 undef, i32 undef, i32 1, i32 3, i32 0, i32 2, i32 undef, i32 undef>
130 %bogus_bo = xor <8 x i32> %extend, <i32 42, i32 43, i32 undef, i32 undef, i32 undef, i32 undef, i32 44, i32 12>
131 %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 6, i32 1, i32 5, i32 4, i32 3, i32 2, i32 0, i32 7>
132 ret <8 x i32> %arbitrary_shuf
135 ; Verify that this isn't limited to high/low halves
136 ; Special case: the undef-ness of the 1st shuffle may be lost if we turn that into vector concat.
138 define <8 x i32> @xor_undef_elts_alt(<4 x i32> %x) {
139 ; SSE-LABEL: xor_undef_elts_alt:
141 ; SSE-NEXT: movaps %xmm0, %xmm1
142 ; SSE-NEXT: movaps {{.*#+}} xmm2 = <u,u,44,12>
143 ; SSE-NEXT: xorps %xmm0, %xmm2
144 ; SSE-NEXT: xorps {{.*}}(%rip), %xmm1
145 ; SSE-NEXT: movaps %xmm1, %xmm0
146 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm2[2,0]
147 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm2[1,0]
148 ; SSE-NEXT: shufps {{.*#+}} xmm2 = xmm2[3,0],xmm1[0,0]
149 ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[3,2],xmm2[2,0]
152 ; AVX-LABEL: xor_undef_elts_alt:
154 ; AVX-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
155 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
156 ; AVX-NEXT: vxorps {{.*}}(%rip), %ymm0, %ymm0
157 ; AVX-NEXT: vmovaps {{.*#+}} ymm1 = [6,1,5,4,3,2,0,7]
158 ; AVX-NEXT: vpermps %ymm0, %ymm1, %ymm0
160 %extend = shufflevector <4 x i32> %x, <4 x i32> undef, <8 x i32> <i32 undef, i32 undef, i32 2, i32 3, i32 0, i32 1, i32 undef, i32 undef>
161 %bogus_bo = xor <8 x i32> %extend, <i32 42, i32 43, i32 undef, i32 undef, i32 undef, i32 undef, i32 44, i32 12>
162 %arbitrary_shuf = shufflevector <8 x i32> %bogus_bo, <8 x i32> undef, <8 x i32> <i32 6, i32 1, i32 5, i32 4, i32 3, i32 2, i32 0, i32 7>
163 ret <8 x i32> %arbitrary_shuf