xref: /llvm-project/llvm/test/CodeGen/Mips/GlobalISel/irtranslator/bitwise.ll (revision 150fd430f66b2f87e3d4c17334bfd7c5ae0db6d7)
1*3b953c37SPetar Jovanovic; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2*3b953c37SPetar Jovanovic; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
3*3b953c37SPetar Jovanovic
4*3b953c37SPetar Jovanovicdefine i32 @shl(i32 %a) {
5*3b953c37SPetar Jovanovic  ; MIPS32-LABEL: name: shl
6*3b953c37SPetar Jovanovic  ; MIPS32: bb.1.entry:
7*3b953c37SPetar Jovanovic  ; MIPS32:   liveins: $a0
8*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY:%[0-9]+]]:_(s32) = COPY $a0
9*3b953c37SPetar Jovanovic  ; MIPS32:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
10*3b953c37SPetar Jovanovic  ; MIPS32:   [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]]
11*3b953c37SPetar Jovanovic  ; MIPS32:   $v0 = COPY [[SHL]](s32)
12*3b953c37SPetar Jovanovic  ; MIPS32:   RetRA implicit $v0
13*3b953c37SPetar Jovanovicentry:
14*3b953c37SPetar Jovanovic  %shl = shl i32 %a, 1
15*3b953c37SPetar Jovanovic  ret i32 %shl
16*3b953c37SPetar Jovanovic}
17*3b953c37SPetar Jovanovic
18*3b953c37SPetar Jovanovicdefine i32 @ashr(i32 %a) {
19*3b953c37SPetar Jovanovic  ; MIPS32-LABEL: name: ashr
20*3b953c37SPetar Jovanovic  ; MIPS32: bb.1.entry:
21*3b953c37SPetar Jovanovic  ; MIPS32:   liveins: $a0
22*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY:%[0-9]+]]:_(s32) = COPY $a0
23*3b953c37SPetar Jovanovic  ; MIPS32:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
24*3b953c37SPetar Jovanovic  ; MIPS32:   [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[COPY]], [[C]]
25*3b953c37SPetar Jovanovic  ; MIPS32:   $v0 = COPY [[ASHR]](s32)
26*3b953c37SPetar Jovanovic  ; MIPS32:   RetRA implicit $v0
27*3b953c37SPetar Jovanovicentry:
28*3b953c37SPetar Jovanovic  %shr = ashr i32 %a, 1
29*3b953c37SPetar Jovanovic  ret i32 %shr
30*3b953c37SPetar Jovanovic}
31*3b953c37SPetar Jovanovic
32*3b953c37SPetar Jovanovicdefine i32 @lshr(i32 %a) {
33*3b953c37SPetar Jovanovic  ; MIPS32-LABEL: name: lshr
34*3b953c37SPetar Jovanovic  ; MIPS32: bb.1.entry:
35*3b953c37SPetar Jovanovic  ; MIPS32:   liveins: $a0
36*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY:%[0-9]+]]:_(s32) = COPY $a0
37*3b953c37SPetar Jovanovic  ; MIPS32:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
38*3b953c37SPetar Jovanovic  ; MIPS32:   [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]]
39*3b953c37SPetar Jovanovic  ; MIPS32:   $v0 = COPY [[LSHR]](s32)
40*3b953c37SPetar Jovanovic  ; MIPS32:   RetRA implicit $v0
41*3b953c37SPetar Jovanovicentry:
42*3b953c37SPetar Jovanovic  %shr = lshr i32 %a, 1
43*3b953c37SPetar Jovanovic  ret i32 %shr
44*3b953c37SPetar Jovanovic}
45*3b953c37SPetar Jovanovic
46*3b953c37SPetar Jovanovicdefine i32 @shlv(i32 %a, i32 %b) {
47*3b953c37SPetar Jovanovic  ; MIPS32-LABEL: name: shlv
48*3b953c37SPetar Jovanovic  ; MIPS32: bb.1.entry:
49*3b953c37SPetar Jovanovic  ; MIPS32:   liveins: $a0, $a1
50*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY:%[0-9]+]]:_(s32) = COPY $a0
51*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
52*3b953c37SPetar Jovanovic  ; MIPS32:   [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[COPY1]]
53*3b953c37SPetar Jovanovic  ; MIPS32:   $v0 = COPY [[SHL]](s32)
54*3b953c37SPetar Jovanovic  ; MIPS32:   RetRA implicit $v0
55*3b953c37SPetar Jovanovicentry:
56*3b953c37SPetar Jovanovic  %shl = shl i32 %a, %b
57*3b953c37SPetar Jovanovic  ret i32 %shl
58*3b953c37SPetar Jovanovic}
59*3b953c37SPetar Jovanovic
60*3b953c37SPetar Jovanovicdefine i32 @ashrv(i32 %a, i32 %b) {
61*3b953c37SPetar Jovanovic  ; MIPS32-LABEL: name: ashrv
62*3b953c37SPetar Jovanovic  ; MIPS32: bb.1.entry:
63*3b953c37SPetar Jovanovic  ; MIPS32:   liveins: $a0, $a1
64*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY:%[0-9]+]]:_(s32) = COPY $a0
65*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
66*3b953c37SPetar Jovanovic  ; MIPS32:   [[ASHR:%[0-9]+]]:_(s32) = G_ASHR [[COPY]], [[COPY1]]
67*3b953c37SPetar Jovanovic  ; MIPS32:   $v0 = COPY [[ASHR]](s32)
68*3b953c37SPetar Jovanovic  ; MIPS32:   RetRA implicit $v0
69*3b953c37SPetar Jovanovicentry:
70*3b953c37SPetar Jovanovic  %shr = ashr i32 %a, %b
71*3b953c37SPetar Jovanovic  ret i32 %shr
72*3b953c37SPetar Jovanovic}
73*3b953c37SPetar Jovanovic
74*3b953c37SPetar Jovanovicdefine i32 @lshrv(i32 %a, i32 %b) {
75*3b953c37SPetar Jovanovic  ; MIPS32-LABEL: name: lshrv
76*3b953c37SPetar Jovanovic  ; MIPS32: bb.1.entry:
77*3b953c37SPetar Jovanovic  ; MIPS32:   liveins: $a0, $a1
78*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY:%[0-9]+]]:_(s32) = COPY $a0
79*3b953c37SPetar Jovanovic  ; MIPS32:   [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
80*3b953c37SPetar Jovanovic  ; MIPS32:   [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[COPY1]]
81*3b953c37SPetar Jovanovic  ; MIPS32:   $v0 = COPY [[LSHR]](s32)
82*3b953c37SPetar Jovanovic  ; MIPS32:   RetRA implicit $v0
83*3b953c37SPetar Jovanovicentry:
84*3b953c37SPetar Jovanovic  %shr = lshr i32 %a, %b
85*3b953c37SPetar Jovanovic  ret i32 %shr
86*3b953c37SPetar Jovanovic}
87*3b953c37SPetar Jovanovic
88