1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
3 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -mattr=+mips32r2 -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32R2
5 declare i32 @llvm.bswap.i32(i32)
6 define i32 @bswap_i32(i32 %x) {
7 ; MIPS32-LABEL: bswap_i32:
8 ; MIPS32: # %bb.0: # %entry
9 ; MIPS32-NEXT: sll $2, $4, 24
10 ; MIPS32-NEXT: srl $1, $4, 24
11 ; MIPS32-NEXT: or $1, $1, $2
12 ; MIPS32-NEXT: andi $2, $4, 65280
13 ; MIPS32-NEXT: sll $2, $2, 8
14 ; MIPS32-NEXT: or $1, $1, $2
15 ; MIPS32-NEXT: srl $2, $4, 8
16 ; MIPS32-NEXT: andi $2, $2, 65280
17 ; MIPS32-NEXT: or $2, $1, $2
21 ; MIPS32R2-LABEL: bswap_i32:
22 ; MIPS32R2: # %bb.0: # %entry
23 ; MIPS32R2-NEXT: wsbh $1, $4
24 ; MIPS32R2-NEXT: rotr $2, $1, 16
25 ; MIPS32R2-NEXT: jr $ra
28 %0 = tail call i32 @llvm.bswap.i32(i32 %x)
32 declare i64 @llvm.bswap.i64(i64)
33 define i64 @bswap_i64(i64 %x) {
34 ; MIPS32-LABEL: bswap_i64:
35 ; MIPS32: # %bb.0: # %entry
36 ; MIPS32-NEXT: sll $2, $5, 24
37 ; MIPS32-NEXT: srl $1, $5, 24
38 ; MIPS32-NEXT: or $1, $1, $2
39 ; MIPS32-NEXT: andi $2, $5, 65280
40 ; MIPS32-NEXT: sll $2, $2, 8
41 ; MIPS32-NEXT: or $1, $1, $2
42 ; MIPS32-NEXT: srl $2, $5, 8
43 ; MIPS32-NEXT: andi $2, $2, 65280
44 ; MIPS32-NEXT: or $2, $1, $2
45 ; MIPS32-NEXT: sll $3, $4, 24
46 ; MIPS32-NEXT: srl $1, $4, 24
47 ; MIPS32-NEXT: or $1, $1, $3
48 ; MIPS32-NEXT: andi $3, $4, 65280
49 ; MIPS32-NEXT: sll $3, $3, 8
50 ; MIPS32-NEXT: or $1, $1, $3
51 ; MIPS32-NEXT: srl $3, $4, 8
52 ; MIPS32-NEXT: andi $3, $3, 65280
53 ; MIPS32-NEXT: or $3, $1, $3
57 ; MIPS32R2-LABEL: bswap_i64:
58 ; MIPS32R2: # %bb.0: # %entry
59 ; MIPS32R2-NEXT: wsbh $1, $5
60 ; MIPS32R2-NEXT: rotr $2, $1, 16
61 ; MIPS32R2-NEXT: wsbh $1, $4
62 ; MIPS32R2-NEXT: rotr $3, $1, 16
63 ; MIPS32R2-NEXT: jr $ra
66 %0 = tail call i64 @llvm.bswap.i64(i64 %x)