1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
4 define i8 @shl_and(i8 %x, i8 %y) nounwind {
5 ; CHECK-LABEL: shl_and:
7 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
8 ; CHECK-NEXT: leal (,%rsi,4), %eax
9 ; CHECK-NEXT: shlb $5, %dil
10 ; CHECK-NEXT: andb %dil, %al
11 ; CHECK-NEXT: # kill: def $al killed $al killed $eax
19 define i16 @shl_or(i16 %x, i16 %y) nounwind {
20 ; CHECK-LABEL: shl_or:
22 ; CHECK-NEXT: movl %edi, %eax
23 ; CHECK-NEXT: shll $7, %esi
24 ; CHECK-NEXT: shll $12, %eax
25 ; CHECK-NEXT: orl %esi, %eax
26 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
34 define i32 @shl_xor(i32 %x, i32 %y) nounwind {
35 ; CHECK-LABEL: shl_xor:
37 ; CHECK-NEXT: movl %edi, %eax
38 ; CHECK-NEXT: shll $7, %esi
39 ; CHECK-NEXT: shll $12, %eax
40 ; CHECK-NEXT: xorl %esi, %eax
48 define i64 @lshr_and(i64 %x, i64 %y) nounwind {
49 ; CHECK-LABEL: lshr_and:
51 ; CHECK-NEXT: movq %rdi, %rax
52 ; CHECK-NEXT: shrq $7, %rsi
53 ; CHECK-NEXT: shrq $12, %rax
54 ; CHECK-NEXT: andq %rsi, %rax
62 define <4 x i32> @lshr_or(<4 x i32> %x, <4 x i32> %y) nounwind {
63 ; CHECK-LABEL: lshr_or:
65 ; CHECK-NEXT: psrld $7, %xmm1
66 ; CHECK-NEXT: psrld $12, %xmm0
67 ; CHECK-NEXT: por %xmm1, %xmm0
69 %sh0 = lshr <4 x i32> %x, <i32 5, i32 5, i32 5, i32 5>
70 %r = or <4 x i32> %sh0, %y
71 %sh1 = lshr <4 x i32> %r, <i32 7, i32 7, i32 7, i32 7>
75 define <8 x i16> @lshr_xor(<8 x i16> %x, <8 x i16> %y) nounwind {
76 ; CHECK-LABEL: lshr_xor:
78 ; CHECK-NEXT: psrlw $7, %xmm1
79 ; CHECK-NEXT: psrlw $12, %xmm0
80 ; CHECK-NEXT: pxor %xmm1, %xmm0
82 %sh0 = lshr <8 x i16> %x, <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>
83 %r = xor <8 x i16> %y, %sh0
84 %sh1 = lshr <8 x i16> %r, <i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7>
89 define <16 x i8> @ashr_and(<16 x i8> %x, <16 x i8> %y) nounwind {
90 ; CHECK-LABEL: ashr_and:
92 ; CHECK-NEXT: psrlw $2, %xmm1
93 ; CHECK-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
94 ; CHECK-NEXT: movdqa {{.*#+}} xmm2 = [32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32]
95 ; CHECK-NEXT: pxor %xmm2, %xmm1
96 ; CHECK-NEXT: psubb %xmm2, %xmm1
97 ; CHECK-NEXT: psrlw $5, %xmm0
98 ; CHECK-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
99 ; CHECK-NEXT: movdqa {{.*#+}} xmm2 = [4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
100 ; CHECK-NEXT: pxor %xmm2, %xmm0
101 ; CHECK-NEXT: psubb %xmm2, %xmm0
102 ; CHECK-NEXT: pand %xmm1, %xmm0
104 %sh0 = ashr <16 x i8> %x, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
105 %r = and <16 x i8> %y, %sh0
106 %sh1 = ashr <16 x i8> %r, <i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2>
110 define <2 x i64> @ashr_or(<2 x i64> %x, <2 x i64> %y) nounwind {
111 ; CHECK-LABEL: ashr_or:
113 ; CHECK-NEXT: pshufd {{.*#+}} xmm2 = xmm1[1,3,2,3]
114 ; CHECK-NEXT: psrad $7, %xmm2
115 ; CHECK-NEXT: psrlq $7, %xmm1
116 ; CHECK-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
117 ; CHECK-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
118 ; CHECK-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,3,2,3]
119 ; CHECK-NEXT: psrad $12, %xmm2
120 ; CHECK-NEXT: psrlq $12, %xmm0
121 ; CHECK-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
122 ; CHECK-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
123 ; CHECK-NEXT: por %xmm1, %xmm0
125 %sh0 = ashr <2 x i64> %x, <i64 5, i64 5>
126 %r = or <2 x i64> %sh0, %y
127 %sh1 = ashr <2 x i64> %r, <i64 7, i64 7>
131 define i32 @ashr_xor(i32 %x, i32 %y) nounwind {
132 ; CHECK-LABEL: ashr_xor:
134 ; CHECK-NEXT: movl %edi, %eax
135 ; CHECK-NEXT: sarl $7, %esi
136 ; CHECK-NEXT: sarl $12, %eax
137 ; CHECK-NEXT: xorl %esi, %eax
139 %sh0 = ashr i32 %x, 5
140 %r = xor i32 %y, %sh0
141 %sh1 = ashr i32 %r, 7
145 define i32 @shr_mismatch_xor(i32 %x, i32 %y) nounwind {
146 ; CHECK-LABEL: shr_mismatch_xor:
148 ; CHECK-NEXT: movl %edi, %eax
149 ; CHECK-NEXT: sarl $5, %eax
150 ; CHECK-NEXT: xorl %esi, %eax
151 ; CHECK-NEXT: shrl $7, %eax
153 %sh0 = ashr i32 %x, 5
154 %r = xor i32 %y, %sh0
155 %sh1 = lshr i32 %r, 7
159 define i32 @ashr_overshift_xor(i32 %x, i32 %y) nounwind {
160 ; CHECK-LABEL: ashr_overshift_xor:
162 ; CHECK-NEXT: movl %edi, %eax
163 ; CHECK-NEXT: sarl $15, %eax
164 ; CHECK-NEXT: xorl %esi, %eax
165 ; CHECK-NEXT: sarl $17, %eax
167 %sh0 = ashr i32 %x, 15
168 %r = xor i32 %y, %sh0
169 %sh1 = ashr i32 %r, 17
173 define i32 @lshr_or_extra_use(i32 %x, i32 %y, ptr %p) nounwind {
174 ; CHECK-LABEL: lshr_or_extra_use:
176 ; CHECK-NEXT: movl %edi, %eax
177 ; CHECK-NEXT: shrl $5, %eax
178 ; CHECK-NEXT: orl %esi, %eax
179 ; CHECK-NEXT: movl %eax, (%rdx)
180 ; CHECK-NEXT: shrl $7, %eax
182 %sh0 = lshr i32 %x, 5
185 %sh1 = lshr i32 %r, 7