[llvm] r373271 - Add partial bswap test to the X86 backend. NFC
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 15:52:28 PDT 2019
Author: deadalnix
Date: Mon Sep 30 15:52:28 2019
New Revision: 373271
URL: http://llvm.org/viewvc/llvm-project?rev=373271&view=rev
Log:
Add partial bswap test to the X86 backend. NFC
Modified:
llvm/trunk/test/CodeGen/X86/bswap_tree.ll
Modified: llvm/trunk/test/CodeGen/X86/bswap_tree.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/bswap_tree.ll?rev=373271&r1=373270&r2=373271&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/bswap_tree.ll (original)
+++ llvm/trunk/test/CodeGen/X86/bswap_tree.ll Mon Sep 30 15:52:28 2019
@@ -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
+}
More information about the llvm-commits
mailing list