Skip to content

Commit 3b44c36

Browse files
committed
[X86] Add test for rotate combining when add X, X is used instead of shl X, 1. NFC
llvm-svn: 370203
1 parent 2dddf3e commit 3b44c36

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

llvm/test/CodeGen/X86/rotate-extract-vector.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,17 @@ define <2 x i64> @no_extract_udiv(<2 x i64> %i) nounwind {
280280
%out = or <2 x i64> %lhs_shift, %rhs_div
281281
ret <2 x i64> %out
282282
}
283+
284+
; DAGCombiner transforms shl X, 1 into add X, X.
285+
define <4 x i32> @extract_add_1(<4 x i32> %i) nounwind {
286+
; CHECK-LABEL: extract_add_1:
287+
; CHECK: # %bb.0:
288+
; CHECK-NEXT: vpaddd %xmm0, %xmm0, %xmm1
289+
; CHECK-NEXT: vpsrld $31, %xmm0, %xmm0
290+
; CHECK-NEXT: vpor %xmm0, %xmm1, %xmm0
291+
; CHECK-NEXT: ret{{[l|q]}}
292+
%ii = add <4 x i32> %i, %i
293+
%rhs = lshr <4 x i32> %i, <i32 31, i32 31, i32 31, i32 31>
294+
%out = or <4 x i32> %ii, %rhs
295+
ret <4 x i32> %out
296+
}

llvm/test/CodeGen/X86/rotate-extract.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,26 @@ define i8 @no_extract_udiv(i8 %i) nounwind {
265265
%out = or i8 %lhs_shift, %rhs_div
266266
ret i8 %out
267267
}
268+
269+
; DAGCombiner transforms shl X, 1 into add X, X.
270+
define i32 @extract_add_1(i32 %i) nounwind {
271+
; X86-LABEL: extract_add_1:
272+
; X86: # %bb.0:
273+
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
274+
; X86-NEXT: leal (%ecx,%ecx), %eax
275+
; X86-NEXT: shrl $31, %ecx
276+
; X86-NEXT: orl %ecx, %eax
277+
; X86-NEXT: retl
278+
;
279+
; X64-LABEL: extract_add_1:
280+
; X64: # %bb.0:
281+
; X64-NEXT: # kill: def $edi killed $edi def $rdi
282+
; X64-NEXT: leal (%rdi,%rdi), %eax
283+
; X64-NEXT: shrl $31, %edi
284+
; X64-NEXT: orl %edi, %eax
285+
; X64-NEXT: retq
286+
%ii = add i32 %i, %i
287+
%rhs = lshr i32 %i, 31
288+
%out = or i32 %ii, %rhs
289+
ret i32 %out
290+
}

0 commit comments

Comments
 (0)