xref: /llvm-project/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/bitreverse.ll (revision 89baeaef2fa9a2441d087a218ac82e11a5d4e548)
198f72a51SPetar Avramovic; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
298f72a51SPetar Avramovic; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
398f72a51SPetar Avramovic; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -mattr=+mips32r2 -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32R2
498f72a51SPetar Avramovic
598f72a51SPetar Avramovicdeclare i32 @llvm.bitreverse.i32(i32)
698f72a51SPetar Avramovicdefine i32 @bitreverse_i32(i32 signext %a) {
798f72a51SPetar Avramovic; MIPS32-LABEL: bitreverse_i32:
898f72a51SPetar Avramovic; MIPS32:       # %bb.0: # %entry
9*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $4, 24
10*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $4, 24
11*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $1, $1, $2
1298f72a51SPetar Avramovic; MIPS32-NEXT:    andi $2, $4, 65280
1398f72a51SPetar Avramovic; MIPS32-NEXT:    sll $2, $2, 8
1498f72a51SPetar Avramovic; MIPS32-NEXT:    or $1, $1, $2
1598f72a51SPetar Avramovic; MIPS32-NEXT:    srl $2, $4, 8
1698f72a51SPetar Avramovic; MIPS32-NEXT:    andi $2, $2, 65280
17*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
18*89baeaefSMatt Arsenault; MIPS32-NEXT:    lui $1, 61680
19*89baeaefSMatt Arsenault; MIPS32-NEXT:    ori $3, $1, 61680
20*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $2, $3
21*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 4
22*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $2, 4
23*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $2, $2, $3
24*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
25*89baeaefSMatt Arsenault; MIPS32-NEXT:    lui $1, 52428
26*89baeaefSMatt Arsenault; MIPS32-NEXT:    ori $3, $1, 52428
27*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $2, $3
28*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 2
29*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $2, 2
30*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $2, $2, $3
31*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
32*89baeaefSMatt Arsenault; MIPS32-NEXT:    lui $1, 43690
33*89baeaefSMatt Arsenault; MIPS32-NEXT:    ori $3, $1, 43690
34*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $2, $3
35*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 1
36*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $2, 1
37*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $2, $2, $3
38*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
3998f72a51SPetar Avramovic; MIPS32-NEXT:    jr $ra
4098f72a51SPetar Avramovic; MIPS32-NEXT:    nop
4198f72a51SPetar Avramovic;
4298f72a51SPetar Avramovic; MIPS32R2-LABEL: bitreverse_i32:
4398f72a51SPetar Avramovic; MIPS32R2:       # %bb.0: # %entry
4498f72a51SPetar Avramovic; MIPS32R2-NEXT:    wsbh $1, $4
45*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    rotr $2, $1, 16
46*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    lui $1, 61680
47*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    ori $3, $1, 61680
48*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $1, $2, $3
49*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $1, $1, 4
50*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $2, $2, 4
51*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $2, $2, $3
52*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $2, $1, $2
53*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    lui $1, 52428
54*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    ori $3, $1, 52428
55*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $1, $2, $3
56*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $1, $1, 2
57*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $2, $2, 2
58*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $2, $2, $3
59*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $2, $1, $2
60*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    lui $1, 43690
61*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    ori $3, $1, 43690
62*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $1, $2, $3
63*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $1, $1, 1
64*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $2, $2, 1
65*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $2, $2, $3
66*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $2, $1, $2
6798f72a51SPetar Avramovic; MIPS32R2-NEXT:    jr $ra
6898f72a51SPetar Avramovic; MIPS32R2-NEXT:    nop
6998f72a51SPetar Avramovicentry:
7098f72a51SPetar Avramovic  %0 = call i32 @llvm.bitreverse.i32(i32 %a)
7198f72a51SPetar Avramovic  ret i32 %0
7298f72a51SPetar Avramovic}
7398f72a51SPetar Avramovic
7498f72a51SPetar Avramovicdeclare i64 @llvm.bitreverse.i64(i64)
7598f72a51SPetar Avramovicdefine i64 @bitreverse_i64(i64 signext %a) {
7698f72a51SPetar Avramovic; MIPS32-LABEL: bitreverse_i64:
7798f72a51SPetar Avramovic; MIPS32:       # %bb.0: # %entry
78*89baeaefSMatt Arsenault; MIPS32-NEXT:    move $3, $4
79*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $5, 24
80*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $5, 24
81*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $1, $1, $2
8298f72a51SPetar Avramovic; MIPS32-NEXT:    andi $2, $5, 65280
8398f72a51SPetar Avramovic; MIPS32-NEXT:    sll $2, $2, 8
8498f72a51SPetar Avramovic; MIPS32-NEXT:    or $1, $1, $2
8598f72a51SPetar Avramovic; MIPS32-NEXT:    srl $2, $5, 8
8698f72a51SPetar Avramovic; MIPS32-NEXT:    andi $2, $2, 65280
87*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
88*89baeaefSMatt Arsenault; MIPS32-NEXT:    lui $1, 61680
89*89baeaefSMatt Arsenault; MIPS32-NEXT:    ori $6, $1, 61680
90*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $2, $6
91*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 4
92*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $2, 4
93*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $2, $2, $6
94*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
95*89baeaefSMatt Arsenault; MIPS32-NEXT:    lui $1, 52428
96*89baeaefSMatt Arsenault; MIPS32-NEXT:    ori $5, $1, 52428
97*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $2, $5
98*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 2
9973a6a164SMuhammad Omair Javaid; MIPS32-NEXT:    sll $2, $2, 2
10073a6a164SMuhammad Omair Javaid; MIPS32-NEXT:    and $2, $2, $5
101*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
102*89baeaefSMatt Arsenault; MIPS32-NEXT:    lui $1, 43690
103*89baeaefSMatt Arsenault; MIPS32-NEXT:    ori $4, $1, 43690
104*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $2, $4
105*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 1
106*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $2, $2, 1
107*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $2, $2, $4
108*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $2, $1, $2
109*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $7, $3, 24
110*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $3, 24
111*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $1, $1, $7
112*89baeaefSMatt Arsenault; MIPS32-NEXT:    andi $7, $3, 65280
113*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $7, $7, 8
114*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $1, $1, $7
115*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $3, $3, 8
116*89baeaefSMatt Arsenault; MIPS32-NEXT:    andi $3, $3, 65280
117*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $3, $1, $3
118*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $3, $6
119*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 4
120*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $3, $3, 4
121*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $3, $3, $6
122*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $3, $1, $3
123*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $3, $5
124*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 2
125*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $3, $3, 2
126*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $3, $3, $5
127*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $3, $1, $3
128*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $1, $3, $4
129*89baeaefSMatt Arsenault; MIPS32-NEXT:    srl $1, $1, 1
130*89baeaefSMatt Arsenault; MIPS32-NEXT:    sll $3, $3, 1
131*89baeaefSMatt Arsenault; MIPS32-NEXT:    and $3, $3, $4
132*89baeaefSMatt Arsenault; MIPS32-NEXT:    or $3, $1, $3
13398f72a51SPetar Avramovic; MIPS32-NEXT:    jr $ra
13498f72a51SPetar Avramovic; MIPS32-NEXT:    nop
13598f72a51SPetar Avramovic;
13698f72a51SPetar Avramovic; MIPS32R2-LABEL: bitreverse_i64:
13798f72a51SPetar Avramovic; MIPS32R2:       # %bb.0: # %entry
138*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    move $1, $4
139*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    wsbh $2, $5
140*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    rotr $3, $2, 16
14198f72a51SPetar Avramovic; MIPS32R2-NEXT:    lui $2, 61680
142*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    ori $6, $2, 61680
143*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $2, $3, $6
144*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $2, $2, 4
145*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $3, $3, 4
146*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $3, $3, $6
147*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $3, $2, $3
148*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    lui $2, 52428
149*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    ori $5, $2, 52428
150*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $2, $3, $5
151*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $2, $2, 2
152*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $3, $3, 2
153*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $3, $3, $5
154*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $3, $2, $3
155*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    lui $2, 43690
156*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    ori $4, $2, 43690
157*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $2, $3, $4
158*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $2, $2, 1
159*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $3, $3, 1
160*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $3, $3, $4
161*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $2, $2, $3
162*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    wsbh $1, $1
163*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    rotr $3, $1, 16
164*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $1, $3, $6
165*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $1, $1, 4
166*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $3, $3, 4
167*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $3, $3, $6
168*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $3, $1, $3
169*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $1, $3, $5
170*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $1, $1, 2
171*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $3, $3, 2
172*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $3, $3, $5
173*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $3, $1, $3
174*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $1, $3, $4
175*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    srl $1, $1, 1
176*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    sll $3, $3, 1
177*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    and $3, $3, $4
178*89baeaefSMatt Arsenault; MIPS32R2-NEXT:    or $3, $1, $3
17998f72a51SPetar Avramovic; MIPS32R2-NEXT:    jr $ra
18098f72a51SPetar Avramovic; MIPS32R2-NEXT:    nop
18198f72a51SPetar Avramovicentry:
18298f72a51SPetar Avramovic  %0 = call i64 @llvm.bitreverse.i64(i64 %a)
18398f72a51SPetar Avramovic  ret i64 %0
18498f72a51SPetar Avramovic}
185