Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86
      3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+movbe | FileCheck %s --check-prefix=X86-MOVBE
      4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
      5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+movbe | FileCheck %s --check-prefix=X64-MOVBE
      6 
      7 declare i64  @llvm.bswap.i64(i64)
      8 declare i128 @llvm.bswap.i128(i128)
      9 declare i256 @llvm.bswap.i256(i256)
     10 
     11 define i64 @bswap_i64(i64 %a0) nounwind {
     12 ; X86-LABEL: bswap_i64:
     13 ; X86:       # %bb.0:
     14 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
     15 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
     16 ; X86-NEXT:    bswapl %eax
     17 ; X86-NEXT:    bswapl %edx
     18 ; X86-NEXT:    retl
     19 ;
     20 ; X86-MOVBE-LABEL: bswap_i64:
     21 ; X86-MOVBE:       # %bb.0:
     22 ; X86-MOVBE-NEXT:    movbel {{[0-9]+}}(%esp), %eax
     23 ; X86-MOVBE-NEXT:    movbel {{[0-9]+}}(%esp), %edx
     24 ; X86-MOVBE-NEXT:    retl
     25 ;
     26 ; X64-LABEL: bswap_i64:
     27 ; X64:       # %bb.0:
     28 ; X64-NEXT:    bswapq %rdi
     29 ; X64-NEXT:    movq %rdi, %rax
     30 ; X64-NEXT:    retq
     31 ;
     32 ; X64-MOVBE-LABEL: bswap_i64:
     33 ; X64-MOVBE:       # %bb.0:
     34 ; X64-MOVBE-NEXT:    bswapq %rdi
     35 ; X64-MOVBE-NEXT:    movq %rdi, %rax
     36 ; X64-MOVBE-NEXT:    retq
     37   %1 = call i64 @llvm.bswap.i64(i64 %a0)
     38   ret i64 %1
     39 }
     40 
     41 define i128 @bswap_i128(i128 %a0) nounwind {
     42 ; X86-LABEL: bswap_i128:
     43 ; X86:       # %bb.0:
     44 ; X86-NEXT:    pushl %edi
     45 ; X86-NEXT:    pushl %esi
     46 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
     47 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
     48 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
     49 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
     50 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
     51 ; X86-NEXT:    bswapl %edi
     52 ; X86-NEXT:    bswapl %esi
     53 ; X86-NEXT:    bswapl %edx
     54 ; X86-NEXT:    bswapl %ecx
     55 ; X86-NEXT:    movl %ecx, 12(%eax)
     56 ; X86-NEXT:    movl %edx, 8(%eax)
     57 ; X86-NEXT:    movl %esi, 4(%eax)
     58 ; X86-NEXT:    movl %edi, (%eax)
     59 ; X86-NEXT:    popl %esi
     60 ; X86-NEXT:    popl %edi
     61 ; X86-NEXT:    retl $4
     62 ;
     63 ; X86-MOVBE-LABEL: bswap_i128:
     64 ; X86-MOVBE:       # %bb.0:
     65 ; X86-MOVBE-NEXT:    pushl %edi
     66 ; X86-MOVBE-NEXT:    pushl %esi
     67 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %eax
     68 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
     69 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %edx
     70 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %esi
     71 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %edi
     72 ; X86-MOVBE-NEXT:    movbel %esi, 12(%eax)
     73 ; X86-MOVBE-NEXT:    movbel %edi, 8(%eax)
     74 ; X86-MOVBE-NEXT:    movbel %edx, 4(%eax)
     75 ; X86-MOVBE-NEXT:    movbel %ecx, (%eax)
     76 ; X86-MOVBE-NEXT:    popl %esi
     77 ; X86-MOVBE-NEXT:    popl %edi
     78 ; X86-MOVBE-NEXT:    retl $4
     79 ;
     80 ; X64-LABEL: bswap_i128:
     81 ; X64:       # %bb.0:
     82 ; X64-NEXT:    bswapq %rsi
     83 ; X64-NEXT:    bswapq %rdi
     84 ; X64-NEXT:    movq %rsi, %rax
     85 ; X64-NEXT:    movq %rdi, %rdx
     86 ; X64-NEXT:    retq
     87 ;
     88 ; X64-MOVBE-LABEL: bswap_i128:
     89 ; X64-MOVBE:       # %bb.0:
     90 ; X64-MOVBE-NEXT:    bswapq %rsi
     91 ; X64-MOVBE-NEXT:    bswapq %rdi
     92 ; X64-MOVBE-NEXT:    movq %rsi, %rax
     93 ; X64-MOVBE-NEXT:    movq %rdi, %rdx
     94 ; X64-MOVBE-NEXT:    retq
     95   %1 = call i128 @llvm.bswap.i128(i128 %a0)
     96   ret i128 %1
     97 }
     98 
     99 define i256 @bswap_i256(i256 %a0) nounwind {
    100 ; X86-LABEL: bswap_i256:
    101 ; X86:       # %bb.0:
    102 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
    103 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    104 ; X86-NEXT:    bswapl %ecx
    105 ; X86-NEXT:    movl %ecx, 28(%eax)
    106 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    107 ; X86-NEXT:    bswapl %ecx
    108 ; X86-NEXT:    movl %ecx, 24(%eax)
    109 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    110 ; X86-NEXT:    bswapl %ecx
    111 ; X86-NEXT:    movl %ecx, 20(%eax)
    112 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    113 ; X86-NEXT:    bswapl %ecx
    114 ; X86-NEXT:    movl %ecx, 16(%eax)
    115 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    116 ; X86-NEXT:    bswapl %ecx
    117 ; X86-NEXT:    movl %ecx, 12(%eax)
    118 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    119 ; X86-NEXT:    bswapl %ecx
    120 ; X86-NEXT:    movl %ecx, 8(%eax)
    121 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    122 ; X86-NEXT:    bswapl %ecx
    123 ; X86-NEXT:    movl %ecx, 4(%eax)
    124 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    125 ; X86-NEXT:    bswapl %ecx
    126 ; X86-NEXT:    movl %ecx, (%eax)
    127 ; X86-NEXT:    retl $4
    128 ;
    129 ; X86-MOVBE-LABEL: bswap_i256:
    130 ; X86-MOVBE:       # %bb.0:
    131 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %eax
    132 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    133 ; X86-MOVBE-NEXT:    movbel %ecx, 28(%eax)
    134 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    135 ; X86-MOVBE-NEXT:    movbel %ecx, 24(%eax)
    136 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    137 ; X86-MOVBE-NEXT:    movbel %ecx, 20(%eax)
    138 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    139 ; X86-MOVBE-NEXT:    movbel %ecx, 16(%eax)
    140 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    141 ; X86-MOVBE-NEXT:    movbel %ecx, 12(%eax)
    142 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    143 ; X86-MOVBE-NEXT:    movbel %ecx, 8(%eax)
    144 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    145 ; X86-MOVBE-NEXT:    movbel %ecx, 4(%eax)
    146 ; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    147 ; X86-MOVBE-NEXT:    movbel %ecx, (%eax)
    148 ; X86-MOVBE-NEXT:    retl $4
    149 ;
    150 ; X64-LABEL: bswap_i256:
    151 ; X64:       # %bb.0:
    152 ; X64-NEXT:    bswapq %r8
    153 ; X64-NEXT:    bswapq %rcx
    154 ; X64-NEXT:    bswapq %rdx
    155 ; X64-NEXT:    bswapq %rsi
    156 ; X64-NEXT:    movq %rsi, 24(%rdi)
    157 ; X64-NEXT:    movq %rdx, 16(%rdi)
    158 ; X64-NEXT:    movq %rcx, 8(%rdi)
    159 ; X64-NEXT:    movq %r8, (%rdi)
    160 ; X64-NEXT:    movq %rdi, %rax
    161 ; X64-NEXT:    retq
    162 ;
    163 ; X64-MOVBE-LABEL: bswap_i256:
    164 ; X64-MOVBE:       # %bb.0:
    165 ; X64-MOVBE-NEXT:    movbeq %rsi, 24(%rdi)
    166 ; X64-MOVBE-NEXT:    movbeq %rdx, 16(%rdi)
    167 ; X64-MOVBE-NEXT:    movbeq %rcx, 8(%rdi)
    168 ; X64-MOVBE-NEXT:    movbeq %r8, (%rdi)
    169 ; X64-MOVBE-NEXT:    movq %rdi, %rax
    170 ; X64-MOVBE-NEXT:    retq
    171   %1 = call i256 @llvm.bswap.i256(i256 %a0)
    172   ret i256 %1
    173 }
    174