Skip to content

Commit 9ed890b

Browse files
committed
[X86] Add test cases to show missed rotate opportunities due to SimplifyDemandedBits.
llvm-svn: 332815
1 parent df4fed6 commit 9ed890b

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

llvm/test/CodeGen/X86/rotate4.ll

+64
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,67 @@ define void @rotate_right_m16(i16* %p, i32 %amount) {
281281
ret void
282282
}
283283

284+
define i32 @rotate_demanded_bits(i32, i32) {
285+
; CHECK-LABEL: rotate_demanded_bits:
286+
; CHECK: # %bb.0:
287+
; CHECK-NEXT: movl %esi, %ecx
288+
; CHECK-NEXT: andl $30, %ecx
289+
; CHECK-NEXT: movl %edi, %eax
290+
; CHECK-NEXT: shll %cl, %eax
291+
; CHECK-NEXT: negl %ecx
292+
; CHECK-NEXT: andb $30, %cl
293+
; CHECK-NEXT: # kill: def $cl killed $cl killed $ecx
294+
; CHECK-NEXT: shrl %cl, %edi
295+
; CHECK-NEXT: orl %eax, %edi
296+
; CHECK-NEXT: movl %edi, %eax
297+
; CHECK-NEXT: retq
298+
%3 = and i32 %1, 30
299+
%4 = shl i32 %0, %3
300+
%5 = sub nsw i32 0, %3
301+
%6 = and i32 %5, 30
302+
%7 = lshr i32 %0, %6
303+
%8 = or i32 %7, %4
304+
ret i32 %8
305+
}
306+
307+
define i32 @rotate_demanded_bits_2(i32, i32) {
308+
; CHECK-LABEL: rotate_demanded_bits_2:
309+
; CHECK: # %bb.0:
310+
; CHECK-NEXT: andb $23, %sil
311+
; CHECK-NEXT: movl %esi, %ecx
312+
; CHECK-NEXT: roll %cl, %edi
313+
; CHECK-NEXT: movl %edi, %eax
314+
; CHECK-NEXT: retq
315+
%3 = and i32 %1, 23
316+
%4 = shl i32 %0, %3
317+
%5 = sub nsw i32 0, %3
318+
%6 = and i32 %5, 31
319+
%7 = lshr i32 %0, %6
320+
%8 = or i32 %7, %4
321+
ret i32 %8
322+
}
323+
324+
define i32 @rotate_demanded_bits_3(i32, i32) {
325+
; CHECK-LABEL: rotate_demanded_bits_3:
326+
; CHECK: # %bb.0:
327+
; CHECK-NEXT: addl %esi, %esi
328+
; CHECK-NEXT: movl %esi, %ecx
329+
; CHECK-NEXT: andb $30, %cl
330+
; CHECK-NEXT: movl %edi, %eax
331+
; CHECK-NEXT: shll %cl, %eax
332+
; CHECK-NEXT: negl %esi
333+
; CHECK-NEXT: andb $30, %sil
334+
; CHECK-NEXT: movl %esi, %ecx
335+
; CHECK-NEXT: shrl %cl, %edi
336+
; CHECK-NEXT: orl %eax, %edi
337+
; CHECK-NEXT: movl %edi, %eax
338+
; CHECK-NEXT: retq
339+
%3 = shl i32 %1, 1
340+
%4 = and i32 %3, 30
341+
%5 = shl i32 %0, %4
342+
%6 = sub i32 0, %3
343+
%7 = and i32 %6, 30
344+
%8 = lshr i32 %0, %7
345+
%9 = or i32 %5, %8
346+
ret i32 %9
347+
}

0 commit comments

Comments
 (0)