[llvm] 69fff1f - [x86] add tests for bswap/rotate; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 09:02:35 PDT 2020


Author: Sanjay Patel
Date: 2020-07-13T12:01:53-04:00
New Revision: 69fff1fc498fe9bcb1ac6d0aa01bd825860e32f3

URL: https://github.com/llvm/llvm-project/commit/69fff1fc498fe9bcb1ac6d0aa01bd825860e32f3
DIFF: https://github.com/llvm/llvm-project/commit/69fff1fc498fe9bcb1ac6d0aa01bd825860e32f3.diff

LOG: [x86] add tests for bswap/rotate; NFC

Added: 
    

Modified: 
    llvm/test/CodeGen/X86/rot16.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/rot16.ll b/llvm/test/CodeGen/X86/rot16.ll
index 5a1a8da3c677..f0cd650624c6 100644
--- a/llvm/test/CodeGen/X86/rot16.ll
+++ b/llvm/test/CodeGen/X86/rot16.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X32
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i686--                | FileCheck %s --check-prefixes=X32,BASE32
+; RUN: llc < %s -mtriple=i686--  -mattr=movbe  | FileCheck %s --check-prefixes=X32,MOVBE32
+; RUN: llc < %s -mtriple=x86_64--              | FileCheck %s --check-prefixes=X64,BASE64
+; RUN: llc < %s -mtriple=x86_64-- -mattr=movbe | FileCheck %s --check-prefixes=X64,MOVBE64
 
 define i16 @foo(i16 %x, i16 %y, i16 %z) nounwind {
 ; X32-LABEL: foo:
@@ -230,3 +232,69 @@ define i16 @rot16_trunc(i32 %x, i32 %y) nounwind {
 	%t3 = trunc i32 %t2 to i16
 	ret i16 %t3
 }
+
+define i16 @rotate16(i16 %x) {
+; X32-LABEL: rotate16:
+; X32:       # %bb.0:
+; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    rolw $8, %ax
+; X32-NEXT:    retl
+;
+; X64-LABEL: rotate16:
+; X64:       # %bb.0:
+; X64-NEXT:    movl %edi, %eax
+; X64-NEXT:    rolw $8, %ax
+; X64-NEXT:    # kill: def $ax killed $ax killed $eax
+; X64-NEXT:    retq
+  %r = call i16 @llvm.fshl.i16(i16 %x, i16 %x, i16 8)
+  ret i16 %r
+}
+
+define void @rotate16_in_place_memory(i8* %p) {
+; X32-LABEL: rotate16_in_place_memory:
+; X32:       # %bb.0:
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    rolw $8, (%eax)
+; X32-NEXT:    retl
+;
+; X64-LABEL: rotate16_in_place_memory:
+; X64:       # %bb.0:
+; X64-NEXT:    rolw $8, (%rdi)
+; X64-NEXT:    retq
+  %p0 = getelementptr i8, i8* %p, i64 0
+  %p1 = getelementptr i8, i8* %p, i64 1
+  %i0 = load i8, i8* %p0, align 1
+  %i1 = load i8, i8* %p1, align 1
+  store i8 %i1, i8* %p0, align 1
+  store i8 %i0, i8* %p1, align 1
+  ret void
+}
+
+define void @rotate16_memory(i8* %p, i8* %q) {
+; X32-LABEL: rotate16_memory:
+; X32:       # %bb.0:
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X32-NEXT:    movzwl (%ecx), %ecx
+; X32-NEXT:    rolw $8, %cx
+; X32-NEXT:    movw %cx, (%eax)
+; X32-NEXT:    retl
+;
+; X64-LABEL: rotate16_memory:
+; X64:       # %bb.0:
+; X64-NEXT:    movzwl (%rdi), %eax
+; X64-NEXT:    rolw $8, %ax
+; X64-NEXT:    movw %ax, (%rsi)
+; X64-NEXT:    retq
+  %p0 = getelementptr i8, i8* %p, i64 0
+  %p1 = getelementptr i8, i8* %p, i64 1
+  %q0 = getelementptr i8, i8* %q, i64 0
+  %q1 = getelementptr i8, i8* %q, i64 1
+  %i0 = load i8, i8* %p0, align 1
+  %i1 = load i8, i8* %p1, align 1
+  store i8 %i1, i8* %q0, align 1
+  store i8 %i0, i8* %q1, align 1
+  ret void
+}
+
+declare i16 @llvm.fshl.i16(i16, i16, i16)


        


More information about the llvm-commits mailing list