Add partial bswap test to the X86 backend. NFC

llvm-svn: 373271
This commit is contained in:
Amaury Sechet 2019-09-30 22:52:28 +00:00
parent e6f98c0073
commit d60c297d1d
1 changed files with 44 additions and 0 deletions

View File

@ -70,3 +70,47 @@ define i32 @test2(i32 %x) nounwind {
%result = or i32 %or0, %or1
ret i32 %result
}
declare i32 @llvm.bswap.i32(i32)
; Match a 32-bit packed halfword bswap, with some subtree
; already converted to a bswap.
define i32 @test3(i32 %x) nounwind {
; CHECK-LABEL: test3:
; CHECK: # %bb.0:
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: andl $16711680, %ecx # imm = 0xFF0000
; CHECK-NEXT: movl %eax, %edx
; CHECK-NEXT: andl $-16777216, %edx # imm = 0xFF000000
; CHECK-NEXT: shll $8, %ecx
; CHECK-NEXT: shrl $8, %edx
; CHECK-NEXT: orl %ecx, %edx
; CHECK-NEXT: bswapl %eax
; CHECK-NEXT: shrl $16, %eax
; CHECK-NEXT: orl %edx, %eax
; CHECK-NEXT: retl
;
; CHECK64-LABEL: test3:
; CHECK64: # %bb.0:
; CHECK64-NEXT: movl %edi, %eax
; CHECK64-NEXT: andl $16711680, %eax # imm = 0xFF0000
; CHECK64-NEXT: movl %edi, %ecx
; CHECK64-NEXT: andl $-16777216, %ecx # imm = 0xFF000000
; CHECK64-NEXT: shll $8, %eax
; CHECK64-NEXT: shrl $8, %ecx
; CHECK64-NEXT: addl %ecx, %eax
; CHECK64-NEXT: bswapl %edi
; CHECK64-NEXT: shrl $16, %edi
; CHECK64-NEXT: orl %edi, %eax
; CHECK64-NEXT: retq
%byte2 = and i32 %x, 16711680 ; 0x00ff0000
%byte3 = and i32 %x, 4278190080 ; 0xff000000
%1 = shl i32 %byte2, 8
%2 = lshr i32 %byte3, 8
%or = or i32 %1, %2
%bswap = call i32 @llvm.bswap.i32(i32 %x)
%3 = lshr i32 %bswap, 16
%result = or i32 %or, %3
ret i32 %result
}