Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
      2 
      3 define i8* @test_memcpy1(i8* %P, i8* %Q) {
      4   ; CHECK: test_memcpy
      5   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1024, i32 1)
      6   ret i8* %P
      7   ; 3rd arg (%edx) -- length
      8   ; CHECK-DAG: movl $1024, %edx
      9   ; CHECK: __llvm_memcpy_element_unordered_atomic_1
     10 }
     11 
     12 define i8* @test_memcpy2(i8* %P, i8* %Q) {
     13   ; CHECK: test_memcpy2
     14   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1024, i32 2)
     15   ret i8* %P
     16   ; 3rd arg (%edx) -- length
     17   ; CHECK-DAG: movl $1024, %edx
     18   ; CHECK: __llvm_memcpy_element_unordered_atomic_2
     19 }
     20 
     21 define i8* @test_memcpy4(i8* %P, i8* %Q) {
     22   ; CHECK: test_memcpy4
     23   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1024, i32 4)
     24   ret i8* %P
     25   ; 3rd arg (%edx) -- length
     26   ; CHECK-DAG: movl $1024, %edx
     27   ; CHECK: __llvm_memcpy_element_unordered_atomic_4
     28 }
     29 
     30 define i8* @test_memcpy8(i8* %P, i8* %Q) {
     31   ; CHECK: test_memcpy8
     32   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 8 %P, i8* align 8 %Q, i32 1024, i32 8)
     33   ret i8* %P
     34   ; 3rd arg (%edx) -- length
     35   ; CHECK-DAG: movl $1024, %edx
     36   ; CHECK: __llvm_memcpy_element_unordered_atomic_8
     37 }
     38 
     39 define i8* @test_memcpy16(i8* %P, i8* %Q) {
     40   ; CHECK: test_memcpy16
     41   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 16 %P, i8* align 16 %Q, i32 1024, i32 16)
     42   ret i8* %P
     43   ; 3rd arg (%edx) -- length
     44   ; CHECK-DAG: movl $1024, %edx
     45   ; CHECK: __llvm_memcpy_element_unordered_atomic_16
     46 }
     47 
     48 define void @test_memcpy_args(i8** %Storage) {
     49   ; CHECK: test_memcpy_args
     50   %Dst = load i8*, i8** %Storage
     51   %Src.addr = getelementptr i8*, i8** %Storage, i64 1
     52   %Src = load i8*, i8** %Src.addr
     53 
     54   ; 1st arg (%rdi)
     55   ; CHECK-DAG: movq (%rdi), [[REG1:%r.+]]
     56   ; CHECK-DAG: movq [[REG1]], %rdi
     57   ; 2nd arg (%rsi)
     58   ; CHECK-DAG: movq 8(%rdi), %rsi
     59   ; 3rd arg (%edx) -- length
     60   ; CHECK-DAG: movl $1024, %edx
     61   ; CHECK: __llvm_memcpy_element_unordered_atomic_4
     62   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %Dst, i8* align 4 %Src, i32 1024, i32 4)
     63   ret void
     64 }
     65 
     66 define i8* @test_memmove1(i8* %P, i8* %Q) {
     67   ; CHECK: test_memmove
     68   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1024, i32 1)
     69   ret i8* %P
     70   ; 3rd arg (%edx) -- length
     71   ; CHECK-DAG: movl $1024, %edx
     72   ; CHECK: __llvm_memmove_element_unordered_atomic_1
     73 }
     74 
     75 define i8* @test_memmove2(i8* %P, i8* %Q) {
     76   ; CHECK: test_memmove2
     77   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1024, i32 2)
     78   ret i8* %P
     79   ; 3rd arg (%edx) -- length
     80   ; CHECK-DAG: movl $1024, %edx
     81   ; CHECK: __llvm_memmove_element_unordered_atomic_2
     82 }
     83 
     84 define i8* @test_memmove4(i8* %P, i8* %Q) {
     85   ; CHECK: test_memmove4
     86   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1024, i32 4)
     87   ret i8* %P
     88   ; 3rd arg (%edx) -- length
     89   ; CHECK-DAG: movl $1024, %edx
     90   ; CHECK: __llvm_memmove_element_unordered_atomic_4
     91 }
     92 
     93 define i8* @test_memmove8(i8* %P, i8* %Q) {
     94   ; CHECK: test_memmove8
     95   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 8 %P, i8* align 8 %Q, i32 1024, i32 8)
     96   ret i8* %P
     97   ; 3rd arg (%edx) -- length
     98   ; CHECK-DAG: movl $1024, %edx
     99   ; CHECK: __llvm_memmove_element_unordered_atomic_8
    100 }
    101 
    102 define i8* @test_memmove16(i8* %P, i8* %Q) {
    103   ; CHECK: test_memmove16
    104   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 16 %P, i8* align 16 %Q, i32 1024, i32 16)
    105   ret i8* %P
    106   ; 3rd arg (%edx) -- length
    107   ; CHECK-DAG: movl $1024, %edx
    108   ; CHECK: __llvm_memmove_element_unordered_atomic_16
    109 }
    110 
    111 define void @test_memmove_args(i8** %Storage) {
    112   ; CHECK: test_memmove_args
    113   %Dst = load i8*, i8** %Storage
    114   %Src.addr = getelementptr i8*, i8** %Storage, i64 1
    115   %Src = load i8*, i8** %Src.addr
    116 
    117   ; 1st arg (%rdi)
    118   ; CHECK-DAG: movq (%rdi), [[REG1:%r.+]]
    119   ; CHECK-DAG: movq [[REG1]], %rdi
    120   ; 2nd arg (%rsi)
    121   ; CHECK-DAG: movq 8(%rdi), %rsi
    122   ; 3rd arg (%edx) -- length
    123   ; CHECK-DAG: movl $1024, %edx
    124   ; CHECK: __llvm_memmove_element_unordered_atomic_4
    125   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %Dst, i8* align 4 %Src, i32 1024, i32 4)
    126   ret void
    127 }
    128 
    129 define i8* @test_memset1(i8* %P, i8 %V) {
    130   ; CHECK: test_memset
    131   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 1 %P, i8 %V, i32 1024, i32 1)
    132   ret i8* %P
    133   ; 3rd arg (%edx) -- length
    134   ; CHECK-DAG: movl $1024, %edx
    135   ; CHECK: __llvm_memset_element_unordered_atomic_1
    136 }
    137 
    138 define i8* @test_memset2(i8* %P, i8 %V) {
    139   ; CHECK: test_memset2
    140   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 2 %P, i8 %V, i32 1024, i32 2)
    141   ret i8* %P
    142   ; 3rd arg (%edx) -- length
    143   ; CHECK-DAG: movl $1024, %edx
    144   ; CHECK: __llvm_memset_element_unordered_atomic_2
    145 }
    146 
    147 define i8* @test_memset4(i8* %P, i8 %V) {
    148   ; CHECK: test_memset4
    149   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 4 %P, i8 %V, i32 1024, i32 4)
    150   ret i8* %P
    151   ; 3rd arg (%edx) -- length
    152   ; CHECK-DAG: movl $1024, %edx
    153   ; CHECK: __llvm_memset_element_unordered_atomic_4
    154 }
    155 
    156 define i8* @test_memset8(i8* %P, i8 %V) {
    157   ; CHECK: test_memset8
    158   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 8 %P, i8 %V, i32 1024, i32 8)
    159   ret i8* %P
    160   ; 3rd arg (%edx) -- length
    161   ; CHECK-DAG: movl $1024, %edx
    162   ; CHECK: __llvm_memset_element_unordered_atomic_8
    163 }
    164 
    165 define i8* @test_memset16(i8* %P, i8 %V) {
    166   ; CHECK: test_memset16
    167   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 16 %P, i8 %V, i32 1024, i32 16)
    168   ret i8* %P
    169   ; 3rd arg (%edx) -- length
    170   ; CHECK-DAG: movl $1024, %edx
    171   ; CHECK: __llvm_memset_element_unordered_atomic_16
    172 }
    173 
    174 define void @test_memset_args(i8** %Storage, i8* %V) {
    175   ; CHECK: test_memset_args
    176   %Dst = load i8*, i8** %Storage
    177   %Val = load i8, i8* %V
    178 
    179   ; 1st arg (%rdi)
    180   ; CHECK-DAG: movq (%rdi), %rdi
    181   ; 2nd arg (%rsi)
    182   ; CHECK-DAG: movzbl (%rsi), %esi
    183   ; 3rd arg (%edx) -- length
    184   ; CHECK-DAG: movl $1024, %edx
    185   ; CHECK: __llvm_memset_element_unordered_atomic_4
    186   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 4 %Dst, i8 %Val, i32 1024, i32 4)
    187   ret void
    188 }
    189 
    190 declare void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind
    191 declare void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind
    192 declare void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* nocapture, i8, i32, i32) nounwind
    193