Skip to content

Commit

Permalink
[x86] add tests to show current memset codegen
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264748 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rotateright committed Mar 29, 2016
1 parent f504359 commit 65a7ad2
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions test/CodeGen/X86/memset-nonzero.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
; NOTE: Assertions have been autogenerated by update_test_checks.py
; RUN: llc -mtriple=x86_64-unknown-unknown < %s -mattr=sse2 | FileCheck %s --check-prefix=ANY --check-prefix=SSE2
; RUN: llc -mtriple=x86_64-unknown-unknown < %s -mattr=avx | FileCheck %s --check-prefix=ANY --check-prefix=AVX --check-prefix=AVX1
; RUN: llc -mtriple=x86_64-unknown-unknown < %s -mattr=avx2 | FileCheck %s --check-prefix=ANY --check-prefix=AVX --check-prefix=AVX2

define void @memset_16_nonzero_bytes(i8* %x) {
; ANY-LABEL: memset_16_nonzero_bytes:
; ANY: movabsq $3038287259199220266, %rax # imm = 0x2A2A2A2A2A2A2A2A
; ANY-NEXT: movq %rax, 8(%rdi)
; ANY-NEXT: movq %rax, (%rdi)
; ANY-NEXT: retq
;
%call = tail call i8* @__memset_chk(i8* %x, i32 42, i64 16, i64 -1)
ret void
}

define void @memset_32_nonzero_bytes(i8* %x) {
; ANY-LABEL: memset_32_nonzero_bytes:
; ANY: movabsq $3038287259199220266, %rax # imm = 0x2A2A2A2A2A2A2A2A
; ANY-NEXT: movq %rax, 24(%rdi)
; ANY-NEXT: movq %rax, 16(%rdi)
; ANY-NEXT: movq %rax, 8(%rdi)
; ANY-NEXT: movq %rax, (%rdi)
; ANY-NEXT: retq
;
%call = tail call i8* @__memset_chk(i8* %x, i32 42, i64 32, i64 -1)
ret void
}

define void @memset_64_nonzero_bytes(i8* %x) {
; ANY-LABEL: memset_64_nonzero_bytes:
; ANY: movabsq $3038287259199220266, %rax # imm = 0x2A2A2A2A2A2A2A2A
; ANY-NEXT: movq %rax, 56(%rdi)
; ANY-NEXT: movq %rax, 48(%rdi)
; ANY-NEXT: movq %rax, 40(%rdi)
; ANY-NEXT: movq %rax, 32(%rdi)
; ANY-NEXT: movq %rax, 24(%rdi)
; ANY-NEXT: movq %rax, 16(%rdi)
; ANY-NEXT: movq %rax, 8(%rdi)
; ANY-NEXT: movq %rax, (%rdi)
; ANY-NEXT: retq
;
%call = tail call i8* @__memset_chk(i8* %x, i32 42, i64 64, i64 -1)
ret void
}

define void @memset_128_nonzero_bytes(i8* %x) {
; ANY-LABEL: memset_128_nonzero_bytes:
; ANY: movabsq $3038287259199220266, %rax # imm = 0x2A2A2A2A2A2A2A2A
; ANY-NEXT: movq %rax, 120(%rdi)
; ANY-NEXT: movq %rax, 112(%rdi)
; ANY-NEXT: movq %rax, 104(%rdi)
; ANY-NEXT: movq %rax, 96(%rdi)
; ANY-NEXT: movq %rax, 88(%rdi)
; ANY-NEXT: movq %rax, 80(%rdi)
; ANY-NEXT: movq %rax, 72(%rdi)
; ANY-NEXT: movq %rax, 64(%rdi)
; ANY-NEXT: movq %rax, 56(%rdi)
; ANY-NEXT: movq %rax, 48(%rdi)
; ANY-NEXT: movq %rax, 40(%rdi)
; ANY-NEXT: movq %rax, 32(%rdi)
; ANY-NEXT: movq %rax, 24(%rdi)
; ANY-NEXT: movq %rax, 16(%rdi)
; ANY-NEXT: movq %rax, 8(%rdi)
; ANY-NEXT: movq %rax, (%rdi)
; ANY-NEXT: retq
;
%call = tail call i8* @__memset_chk(i8* %x, i32 42, i64 128, i64 -1)
ret void
}

define void @memset_256_nonzero_bytes(i8* %x) {
; ANY-LABEL: memset_256_nonzero_bytes:
; ANY: pushq %rax
; ANY-NEXT: .Ltmp0:
; ANY-NEXT: .cfi_def_cfa_offset 16
; ANY-NEXT: movl $42, %esi
; ANY-NEXT: movl $256, %edx # imm = 0x100
; ANY-NEXT: callq memset
; ANY-NEXT: popq %rax
; ANY-NEXT: retq
;
%call = tail call i8* @__memset_chk(i8* %x, i32 42, i64 256, i64 -1)
ret void
}

declare i8* @__memset_chk(i8*, i32, i64, i64)

0 comments on commit 65a7ad2

Please sign in to comment.