Commit 69fff1fc authored by Sanjay Patel's avatar Sanjay Patel
Browse files

[x86] add tests for bswap/rotate; NFC

parent 8f7d3430
Loading
Loading
Loading
Loading
+70 −2
Original line number Diff line number Diff line
; 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)