blob: 37d9bc769d307b9eaebbf132adc9e9d635e9768c [file] [log] [blame]
Petar Jovanovice578e972016-04-11 15:24:23 +00001; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \
2; RUN: -check-prefix=GP32 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
3; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \
4; RUN: -check-prefix=GP32 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
5; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | FileCheck %s -check-prefix=GP32 \
Daniel Sanders17793142015-02-18 16:24:50 +00006; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00007; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | FileCheck %s -check-prefix=GP32 \
Daniel Sanders17793142015-02-18 16:24:50 +00008; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00009; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | FileCheck %s -check-prefix=GP32 \
Daniel Sanders17793142015-02-18 16:24:50 +000010; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000011; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000012; RUN: -check-prefix=GP32 -check-prefix=R6 -check-prefix=R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000013; RUN: llc < %s -march=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000014; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000015; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000016; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000017; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000018; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000019; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000020; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 \
21; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000022; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000023; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 \
24; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000025; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000026; RUN: -check-prefix=R2-R5 -check-prefix=R2-R6 \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000027; RUN: -check-prefix=GP64-NOT-R6 -check-prefix=NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000028; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000029; RUN: -check-prefix=64R6 -check-prefix=R6 -check-prefix=R2-R6
Zlatko Buljan58d6a952016-04-13 08:02:26 +000030; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips -relocation-model=pic | FileCheck %s \
31; RUN: -check-prefix=MM -check-prefix=MMR3 -check-prefix=MM32
32; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
33; RUN: -check-prefix=MM -check-prefix=MMR6 -check-prefix=MM32
34; RUN: llc < %s -march=mips -mcpu=mips64r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
35; RUN: -check-prefix=MM -check-prefix=MMR6 -check-prefix=MM64
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000036
37define signext i1 @urem_i1(i1 signext %a, i1 signext %b) {
38entry:
39; ALL-LABEL: urem_i1:
40
41 ; NOT-R6: andi $[[T0:[0-9]+]], $5, 1
42 ; NOT-R6: andi $[[T1:[0-9]+]], $4, 1
43 ; NOT-R6: divu $zero, $[[T1]], $[[T0]]
44 ; NOT-R6: teq $[[T0]], $zero, 7
45 ; NOT-R6: mfhi $[[T2:[0-9]+]]
46 ; NOT-R6: sll $[[T3:[0-9]+]], $[[T2]], 31
47 ; NOT-R6: sra $2, $[[T3]], 31
48
49 ; R6: andi $[[T0:[0-9]+]], $5, 1
50 ; R6: andi $[[T1:[0-9]+]], $4, 1
51 ; R6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
52 ; R6: teq $[[T0]], $zero, 7
53 ; R6: sll $[[T3:[0-9]+]], $[[T2]], 31
54 ; R6: sra $2, $[[T3]], 31
55
Zlatko Buljan58d6a952016-04-13 08:02:26 +000056 ; MMR3: andi16 $[[T0:[0-9]+]], $5, 1
57 ; MMR3: andi16 $[[T1:[0-9]+]], $4, 1
58 ; MMR3: divu $zero, $[[T1]], $[[T0]]
59 ; MMR3: teq $[[T0]], $zero, 7
60 ; MMR3: mfhi $[[T2:[0-9]+]]
61 ; MMR3: sll $[[T3:[0-9]+]], $[[T2]], 31
62 ; MMR3: sra $2, $[[T3]], 31
63
64 ; MMR6: andi16 $[[T0:[0-9]+]], $5, 1
65 ; MMR6: andi16 $[[T1:[0-9]+]], $4, 1
66 ; MMR6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
67 ; MMR6: teq $[[T0]], $zero, 7
68 ; MMR6: sll $[[T3:[0-9]+]], $[[T2]], 31
69 ; MMR6: sra $2, $[[T3]], 31
70
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000071 %r = urem i1 %a, %b
72 ret i1 %r
73}
74
75define signext i8 @urem_i8(i8 signext %a, i8 signext %b) {
76entry:
77; ALL-LABEL: urem_i8:
78
79 ; NOT-R2-R6: andi $[[T0:[0-9]+]], $5, 255
80 ; NOT-R2-R6: andi $[[T1:[0-9]+]], $4, 255
81 ; NOT-R2-R6: divu $zero, $[[T1]], $[[T0]]
82 ; NOT-R2-R6: teq $[[T0]], $zero, 7
83 ; NOT-R2-R6: mfhi $[[T2:[0-9]+]]
84 ; NOT-R2-R6: sll $[[T3:[0-9]+]], $[[T2]], 24
85 ; NOT-R2-R6: sra $2, $[[T3]], 24
86
Daniel Sanders17793142015-02-18 16:24:50 +000087 ; R2-R5: andi $[[T0:[0-9]+]], $5, 255
88 ; R2-R5: andi $[[T1:[0-9]+]], $4, 255
89 ; R2-R5: divu $zero, $[[T1]], $[[T0]]
90 ; R2-R5: teq $[[T0]], $zero, 7
91 ; R2-R5: mfhi $[[T2:[0-9]+]]
92 ; R2-R5: seb $2, $[[T2]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000093
94 ; R6: andi $[[T0:[0-9]+]], $5, 255
95 ; R6: andi $[[T1:[0-9]+]], $4, 255
96 ; R6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
97 ; R6: teq $[[T0]], $zero, 7
98 ; R6: seb $2, $[[T2]]
99
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000100 ; MMR3: andi16 $[[T0:[0-9]+]], $5, 255
101 ; MMR3: andi16 $[[T1:[0-9]+]], $4, 255
102 ; MMR3: divu $zero, $[[T1]], $[[T0]]
103 ; MMR3: teq $[[T0]], $zero, 7
104 ; MMR3: mfhi $[[T2:[0-9]+]]
105 ; MMR3: seb $2, $[[T2]]
106
107 ; MMR6: andi16 $[[T0:[0-9]+]], $5, 255
108 ; MMR6: andi16 $[[T1:[0-9]+]], $4, 255
109 ; MMR6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
110 ; MMR6: teq $[[T0]], $zero, 7
111 ; MMR6: seb $2, $[[T2]]
112
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000113 %r = urem i8 %a, %b
114 ret i8 %r
115}
116
117define signext i16 @urem_i16(i16 signext %a, i16 signext %b) {
118entry:
119; ALL-LABEL: urem_i16:
120
121 ; NOT-R2-R6: andi $[[T0:[0-9]+]], $5, 65535
122 ; NOT-R2-R6: andi $[[T1:[0-9]+]], $4, 65535
123 ; NOT-R2-R6: divu $zero, $[[T1]], $[[T0]]
124 ; NOT-R2-R6: teq $[[T0]], $zero, 7
125 ; NOT-R2-R6: mfhi $[[T2:[0-9]+]]
126 ; NOT-R2-R6: sll $[[T3:[0-9]+]], $[[T2]], 16
127 ; NOT-R2-R6: sra $2, $[[T3]], 16
128
Daniel Sanders17793142015-02-18 16:24:50 +0000129 ; R2-R5: andi $[[T0:[0-9]+]], $5, 65535
130 ; R2-R5: andi $[[T1:[0-9]+]], $4, 65535
131 ; R2-R5: divu $zero, $[[T1]], $[[T0]]
132 ; R2-R5: teq $[[T0]], $zero, 7
133 ; R2-R5: mfhi $[[T3:[0-9]+]]
134 ; R2-R5: seh $2, $[[T2]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000135
136 ; R6: andi $[[T0:[0-9]+]], $5, 65535
137 ; R6: andi $[[T1:[0-9]+]], $4, 65535
138 ; R6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
139 ; R6: teq $[[T0]], $zero, 7
140 ; R6: seh $2, $[[T2]]
141
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000142 ; MMR3: andi16 $[[T0:[0-9]+]], $5, 65535
143 ; MMR3: andi16 $[[T1:[0-9]+]], $4, 65535
144 ; MMR3: divu $zero, $[[T1]], $[[T0]]
145 ; MMR3: teq $[[T0]], $zero, 7
146 ; MMR3: mfhi $[[T2:[0-9]+]]
147 ; MMR3: seh $2, $[[T2]]
148
149 ; MMR6: andi16 $[[T0:[0-9]+]], $5, 65535
150 ; MMR6: andi16 $[[T1:[0-9]+]], $4, 65535
151 ; MMR6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
152 ; MMR6: teq $[[T0]], $zero, 7
153 ; MMR6: seh $2, $[[T2]]
154
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000155 %r = urem i16 %a, %b
156 ret i16 %r
157}
158
159define signext i32 @urem_i32(i32 signext %a, i32 signext %b) {
160entry:
161; ALL-LABEL: urem_i32:
162
163 ; NOT-R6: divu $zero, $4, $5
164 ; NOT-R6: teq $5, $zero, 7
165 ; NOT-R6: mfhi $2
166
167 ; R6: modu $2, $4, $5
168 ; R6: teq $5, $zero, 7
169
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000170 ; MMR3: divu $zero, $4, $5
171 ; MMR3: teq $5, $zero, 7
172 ; MMR3: mfhi $2
173
174 ; MMR6: modu $2, $4, $5
175 ; MMR6: teq $5, $zero, 7
176
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000177 %r = urem i32 %a, %b
178 ret i32 %r
179}
180
181define signext i64 @urem_i64(i64 signext %a, i64 signext %b) {
182entry:
183; ALL-LABEL: urem_i64:
184
185 ; GP32: lw $25, %call16(__umoddi3)($gp)
186
187 ; GP64-NOT-R6: ddivu $zero, $4, $5
188 ; GP64-NOT-R6: teq $5, $zero, 7
189 ; GP64-NOT-R6: mfhi $2
190
191 ; 64R6: dmodu $2, $4, $5
192 ; 64R6: teq $5, $zero, 7
193
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000194 ; MM32: lw $25, %call16(__umoddi3)($2)
195
196 ; MM64: dmodu $2, $4, $5
197 ; MM64: teq $5, $zero, 7
198
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000199 %r = urem i64 %a, %b
200 ret i64 %r
201}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000202
203define signext i128 @urem_i128(i128 signext %a, i128 signext %b) {
204entry:
205 ; ALL-LABEL: urem_i128:
206
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000207 ; GP32: lw $25, %call16(__umodti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000208
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000209 ; GP64-NOT-R6: ld $25, %call16(__umodti3)($gp)
210 ; 64-R6: ld $25, %call16(__umodti3)($gp)
211
212 ; MM32: lw $25, %call16(__umodti3)($2)
213
214 ; MM64: ld $25, %call16(__umodti3)($2)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000215
216 %r = urem i128 %a, %b
217 ret i128 %r
218}