aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/bswap-wide-int.ll
blob: db48eb80de4b98fed14144605e1787687cd81a3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+movbe | FileCheck %s --check-prefix=X86-MOVBE
; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+movbe | FileCheck %s --check-prefix=X64-MOVBE

declare i64  @llvm.bswap.i64(i64)
declare i128 @llvm.bswap.i128(i128)
declare i256 @llvm.bswap.i256(i256)

define i64 @bswap_i64(i64 %a0) nounwind {
; X86-LABEL: bswap_i64:
; X86:       # BB#0:
; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-NEXT:    bswapl %eax
; X86-NEXT:    bswapl %edx
; X86-NEXT:    retl
;
; X86-MOVBE-LABEL: bswap_i64:
; X86-MOVBE:       # BB#0:
; X86-MOVBE-NEXT:    movbel {{[0-9]+}}(%esp), %eax
; X86-MOVBE-NEXT:    movbel {{[0-9]+}}(%esp), %edx
; X86-MOVBE-NEXT:    retl
;
; X64-LABEL: bswap_i64:
; X64:       # BB#0:
; X64-NEXT:    bswapq %rdi
; X64-NEXT:    movq %rdi, %rax
; X64-NEXT:    retq
;
; X64-MOVBE-LABEL: bswap_i64:
; X64-MOVBE:       # BB#0:
; X64-MOVBE-NEXT:    bswapq %rdi
; X64-MOVBE-NEXT:    movq %rdi, %rax
; X64-MOVBE-NEXT:    retq
  %1 = call i64 @llvm.bswap.i64(i64 %a0)
  ret i64 %1
}

define i128 @bswap_i128(i128 %a0) nounwind {
; X86-LABEL: bswap_i128:
; X86:       # BB#0:
; X86-NEXT:    pushl %edi
; X86-NEXT:    pushl %esi
; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
; X86-NEXT:    bswapl %edi
; X86-NEXT:    bswapl %esi
; X86-NEXT:    bswapl %edx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 12(%eax)
; X86-NEXT:    movl %edx, 8(%eax)
; X86-NEXT:    movl %esi, 4(%eax)
; X86-NEXT:    movl %edi, (%eax)
; X86-NEXT:    popl %esi
; X86-NEXT:    popl %edi
; X86-NEXT:    retl $4
;
; X86-MOVBE-LABEL: bswap_i128:
; X86-MOVBE:       # BB#0:
; X86-MOVBE-NEXT:    pushl %edi
; X86-MOVBE-NEXT:    pushl %esi
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %edx
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %esi
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %edi
; X86-MOVBE-NEXT:    movbel %esi, 12(%eax)
; X86-MOVBE-NEXT:    movbel %edi, 8(%eax)
; X86-MOVBE-NEXT:    movbel %ecx, 4(%eax)
; X86-MOVBE-NEXT:    movbel %edx, (%eax)
; X86-MOVBE-NEXT:    popl %esi
; X86-MOVBE-NEXT:    popl %edi
; X86-MOVBE-NEXT:    retl $4
;
; X64-LABEL: bswap_i128:
; X64:       # BB#0:
; X64-NEXT:    bswapq %rsi
; X64-NEXT:    bswapq %rdi
; X64-NEXT:    movq %rsi, %rax
; X64-NEXT:    movq %rdi, %rdx
; X64-NEXT:    retq
;
; X64-MOVBE-LABEL: bswap_i128:
; X64-MOVBE:       # BB#0:
; X64-MOVBE-NEXT:    bswapq %rsi
; X64-MOVBE-NEXT:    bswapq %rdi
; X64-MOVBE-NEXT:    movq %rsi, %rax
; X64-MOVBE-NEXT:    movq %rdi, %rdx
; X64-MOVBE-NEXT:    retq
  %1 = call i128 @llvm.bswap.i128(i128 %a0)
  ret i128 %1
}

define i256 @bswap_i256(i256 %a0) nounwind {
; X86-LABEL: bswap_i256:
; X86:       # BB#0:
; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 28(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 24(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 20(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 16(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 12(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 8(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, 4(%eax)
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    bswapl %ecx
; X86-NEXT:    movl %ecx, (%eax)
; X86-NEXT:    retl $4
;
; X86-MOVBE-LABEL: bswap_i256:
; X86-MOVBE:       # BB#0:
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 28(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 24(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 20(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 16(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 12(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 8(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, 4(%eax)
; X86-MOVBE-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-MOVBE-NEXT:    movbel %ecx, (%eax)
; X86-MOVBE-NEXT:    retl $4
;
; X64-LABEL: bswap_i256:
; X64:       # BB#0:
; X64-NEXT:    bswapq %r8
; X64-NEXT:    bswapq %rcx
; X64-NEXT:    bswapq %rdx
; X64-NEXT:    bswapq %rsi
; X64-NEXT:    movq %rsi, 24(%rdi)
; X64-NEXT:    movq %rdx, 16(%rdi)
; X64-NEXT:    movq %rcx, 8(%rdi)
; X64-NEXT:    movq %r8, (%rdi)
; X64-NEXT:    movq %rdi, %rax
; X64-NEXT:    retq
;
; X64-MOVBE-LABEL: bswap_i256:
; X64-MOVBE:       # BB#0:
; X64-MOVBE-NEXT:    movbeq %rsi, 24(%rdi)
; X64-MOVBE-NEXT:    movbeq %rdx, 16(%rdi)
; X64-MOVBE-NEXT:    movbeq %rcx, 8(%rdi)
; X64-MOVBE-NEXT:    movbeq %r8, (%rdi)
; X64-MOVBE-NEXT:    movq %rdi, %rax
; X64-MOVBE-NEXT:    retq
  %1 = call i256 @llvm.bswap.i256(i256 %a0)
  ret i256 %1
}