summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll
blob: 662bcdf757b6d27ea31f93618186c1edaa902728 (plain)
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
174
175
176
177
178
179
180
181
182
183
184
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -mattr=+mips32r2 -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32R2

declare i32 @llvm.bitreverse.i32(i32)
define i32 @bitreverse_i32(i32 signext %a) {
; MIPS32-LABEL: bitreverse_i32:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    sll $1, $4, 24
; MIPS32-NEXT:    srl $2, $4, 24
; MIPS32-NEXT:    or $1, $2, $1
; MIPS32-NEXT:    andi $2, $4, 65280
; MIPS32-NEXT:    sll $2, $2, 8
; MIPS32-NEXT:    or $1, $1, $2
; MIPS32-NEXT:    srl $2, $4, 8
; MIPS32-NEXT:    andi $2, $2, 65280
; MIPS32-NEXT:    or $1, $1, $2
; MIPS32-NEXT:    lui $2, 61680
; MIPS32-NEXT:    ori $2, $2, 61680
; MIPS32-NEXT:    and $3, $1, $2
; MIPS32-NEXT:    srl $3, $3, 4
; MIPS32-NEXT:    sll $1, $1, 4
; MIPS32-NEXT:    and $1, $1, $2
; MIPS32-NEXT:    or $1, $3, $1
; MIPS32-NEXT:    lui $2, 52428
; MIPS32-NEXT:    ori $2, $2, 52428
; MIPS32-NEXT:    and $3, $1, $2
; MIPS32-NEXT:    srl $3, $3, 2
; MIPS32-NEXT:    sll $1, $1, 2
; MIPS32-NEXT:    and $1, $1, $2
; MIPS32-NEXT:    or $1, $3, $1
; MIPS32-NEXT:    lui $2, 43690
; MIPS32-NEXT:    ori $2, $2, 43690
; MIPS32-NEXT:    and $3, $1, $2
; MIPS32-NEXT:    srl $3, $3, 1
; MIPS32-NEXT:    sll $1, $1, 1
; MIPS32-NEXT:    and $1, $1, $2
; MIPS32-NEXT:    or $2, $3, $1
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
;
; MIPS32R2-LABEL: bitreverse_i32:
; MIPS32R2:       # %bb.0: # %entry
; MIPS32R2-NEXT:    wsbh $1, $4
; MIPS32R2-NEXT:    rotr $1, $1, 16
; MIPS32R2-NEXT:    lui $2, 61680
; MIPS32R2-NEXT:    ori $2, $2, 61680
; MIPS32R2-NEXT:    and $3, $1, $2
; MIPS32R2-NEXT:    srl $3, $3, 4
; MIPS32R2-NEXT:    sll $1, $1, 4
; MIPS32R2-NEXT:    and $1, $1, $2
; MIPS32R2-NEXT:    or $1, $3, $1
; MIPS32R2-NEXT:    lui $2, 52428
; MIPS32R2-NEXT:    ori $2, $2, 52428
; MIPS32R2-NEXT:    and $3, $1, $2
; MIPS32R2-NEXT:    srl $3, $3, 2
; MIPS32R2-NEXT:    sll $1, $1, 2
; MIPS32R2-NEXT:    and $1, $1, $2
; MIPS32R2-NEXT:    or $1, $3, $1
; MIPS32R2-NEXT:    lui $2, 43690
; MIPS32R2-NEXT:    ori $2, $2, 43690
; MIPS32R2-NEXT:    and $3, $1, $2
; MIPS32R2-NEXT:    srl $3, $3, 1
; MIPS32R2-NEXT:    sll $1, $1, 1
; MIPS32R2-NEXT:    and $1, $1, $2
; MIPS32R2-NEXT:    or $2, $3, $1
; MIPS32R2-NEXT:    jr $ra
; MIPS32R2-NEXT:    nop
entry:
  %0 = call i32 @llvm.bitreverse.i32(i32 %a)
  ret i32 %0
}

declare i64 @llvm.bitreverse.i64(i64)
define i64 @bitreverse_i64(i64 signext %a) {
; MIPS32-LABEL: bitreverse_i64:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    sll $1, $5, 24
; MIPS32-NEXT:    srl $2, $5, 24
; MIPS32-NEXT:    or $1, $2, $1
; MIPS32-NEXT:    andi $2, $5, 65280
; MIPS32-NEXT:    sll $2, $2, 8
; MIPS32-NEXT:    or $1, $1, $2
; MIPS32-NEXT:    srl $2, $5, 8
; MIPS32-NEXT:    andi $2, $2, 65280
; MIPS32-NEXT:    or $1, $1, $2
; MIPS32-NEXT:    lui $2, 61680
; MIPS32-NEXT:    ori $2, $2, 61680
; MIPS32-NEXT:    and $3, $1, $2
; MIPS32-NEXT:    srl $3, $3, 4
; MIPS32-NEXT:    sll $1, $1, 4
; MIPS32-NEXT:    and $1, $1, $2
; MIPS32-NEXT:    or $1, $3, $1
; MIPS32-NEXT:    lui $3, 52428
; MIPS32-NEXT:    ori $3, $3, 52428
; MIPS32-NEXT:    and $5, $1, $3
; MIPS32-NEXT:    srl $5, $5, 2
; MIPS32-NEXT:    sll $1, $1, 2
; MIPS32-NEXT:    and $1, $1, $3
; MIPS32-NEXT:    or $1, $5, $1
; MIPS32-NEXT:    lui $5, 43690
; MIPS32-NEXT:    ori $5, $5, 43690
; MIPS32-NEXT:    and $6, $1, $5
; MIPS32-NEXT:    srl $6, $6, 1
; MIPS32-NEXT:    sll $1, $1, 1
; MIPS32-NEXT:    and $1, $1, $5
; MIPS32-NEXT:    or $1, $6, $1
; MIPS32-NEXT:    sll $6, $4, 24
; MIPS32-NEXT:    srl $7, $4, 24
; MIPS32-NEXT:    or $6, $7, $6
; MIPS32-NEXT:    andi $7, $4, 65280
; MIPS32-NEXT:    sll $7, $7, 8
; MIPS32-NEXT:    or $6, $6, $7
; MIPS32-NEXT:    srl $4, $4, 8
; MIPS32-NEXT:    andi $4, $4, 65280
; MIPS32-NEXT:    or $4, $6, $4
; MIPS32-NEXT:    and $6, $4, $2
; MIPS32-NEXT:    srl $6, $6, 4
; MIPS32-NEXT:    sll $4, $4, 4
; MIPS32-NEXT:    and $2, $4, $2
; MIPS32-NEXT:    or $2, $6, $2
; MIPS32-NEXT:    and $4, $2, $3
; MIPS32-NEXT:    srl $4, $4, 2
; MIPS32-NEXT:    sll $2, $2, 2
; MIPS32-NEXT:    and $2, $2, $3
; MIPS32-NEXT:    or $2, $4, $2
; MIPS32-NEXT:    and $3, $2, $5
; MIPS32-NEXT:    srl $3, $3, 1
; MIPS32-NEXT:    sll $2, $2, 1
; MIPS32-NEXT:    and $2, $2, $5
; MIPS32-NEXT:    or $3, $3, $2
; MIPS32-NEXT:    move $2, $1
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
;
; MIPS32R2-LABEL: bitreverse_i64:
; MIPS32R2:       # %bb.0: # %entry
; MIPS32R2-NEXT:    wsbh $1, $5
; MIPS32R2-NEXT:    rotr $1, $1, 16
; MIPS32R2-NEXT:    lui $2, 61680
; MIPS32R2-NEXT:    ori $2, $2, 61680
; MIPS32R2-NEXT:    and $3, $1, $2
; MIPS32R2-NEXT:    srl $3, $3, 4
; MIPS32R2-NEXT:    sll $1, $1, 4
; MIPS32R2-NEXT:    and $1, $1, $2
; MIPS32R2-NEXT:    or $1, $3, $1
; MIPS32R2-NEXT:    lui $3, 52428
; MIPS32R2-NEXT:    ori $3, $3, 52428
; MIPS32R2-NEXT:    and $5, $1, $3
; MIPS32R2-NEXT:    srl $5, $5, 2
; MIPS32R2-NEXT:    sll $1, $1, 2
; MIPS32R2-NEXT:    and $1, $1, $3
; MIPS32R2-NEXT:    or $1, $5, $1
; MIPS32R2-NEXT:    lui $5, 43690
; MIPS32R2-NEXT:    ori $5, $5, 43690
; MIPS32R2-NEXT:    and $6, $1, $5
; MIPS32R2-NEXT:    srl $6, $6, 1
; MIPS32R2-NEXT:    sll $1, $1, 1
; MIPS32R2-NEXT:    and $1, $1, $5
; MIPS32R2-NEXT:    or $1, $6, $1
; MIPS32R2-NEXT:    wsbh $4, $4
; MIPS32R2-NEXT:    rotr $4, $4, 16
; MIPS32R2-NEXT:    and $6, $4, $2
; MIPS32R2-NEXT:    srl $6, $6, 4
; MIPS32R2-NEXT:    sll $4, $4, 4
; MIPS32R2-NEXT:    and $2, $4, $2
; MIPS32R2-NEXT:    or $2, $6, $2
; MIPS32R2-NEXT:    and $4, $2, $3
; MIPS32R2-NEXT:    srl $4, $4, 2
; MIPS32R2-NEXT:    sll $2, $2, 2
; MIPS32R2-NEXT:    and $2, $2, $3
; MIPS32R2-NEXT:    or $2, $4, $2
; MIPS32R2-NEXT:    and $3, $2, $5
; MIPS32R2-NEXT:    srl $3, $3, 1
; MIPS32R2-NEXT:    sll $2, $2, 1
; MIPS32R2-NEXT:    and $2, $2, $5
; MIPS32R2-NEXT:    or $3, $3, $2
; MIPS32R2-NEXT:    move $2, $1
; MIPS32R2-NEXT:    jr $ra
; MIPS32R2-NEXT:    nop
entry:
  %0 = call i64 @llvm.bitreverse.i64(i64 %a)
  ret i64 %0
}
OpenPOWER on IntegriCloud