blob: defd25bb41acf4c0d05a94fff62a0b0175eed639 [file] [log] [blame]
Petar Jovanovice578e972016-04-11 15:24:23 +00001; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00002; RUN: -check-prefixes=ALL,NOT-R6,NOT-R2-R6,GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00003; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00004; RUN: -check-prefixes=ALL,NOT-R6,NOT-R2-R6,GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00005; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00006; RUN: -check-prefixes=ALL,NOT-R6,R2-R5,GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00007; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00008; RUN: -check-prefixes=ALL,NOT-R6,R2-R5,GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00009; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000010; RUN: -check-prefixes=ALL,NOT-R6,R2-R5,GP32
Petar Jovanovice578e972016-04-11 15:24:23 +000011; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000012; RUN: -check-prefixes=ALL,R6,GP32
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000013
Petar Jovanovice578e972016-04-11 15:24:23 +000014; RUN: llc < %s -march=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000015; RUN: -check-prefixes=ALL,NOT-R6,NOT-R2-R6,GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000016; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000017; RUN: -check-prefixes=ALL,NOT-R6,NOT-R2-R6,GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000018; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000019; RUN: -check-prefixes=ALL,NOT-R6,NOT-R2-R6,GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000020; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000021; RUN: -check-prefixes=ALL,NOT-R6,R2-R5,GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000022; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000023; RUN: -check-prefixes=ALL,NOT-R6,R2-R5,GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000024; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000025; RUN: -check-prefixes=ALL,NOT-R6,R2-R5,GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000026; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000027; RUN: -check-prefixes=ALL,R6,64R6
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000028
Zlatko Buljan58d6a952016-04-13 08:02:26 +000029; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000030; RUN: -check-prefixes=ALL,MMR3,MM32
Zlatko Buljan58d6a952016-04-13 08:02:26 +000031; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000032; RUN: -check-prefixes=ALL,MMR6,MM32
Daniel Sandersde393322016-06-23 12:42:53 +000033; RUN: llc < %s -march=mips -mcpu=mips64r6 -mattr=+micromips -target-abi n64 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000034; RUN: -check-prefixes=ALL,MMR6,MM64
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000035
36define signext i1 @sdiv_i1(i1 signext %a, i1 signext %b) {
37entry:
38; ALL-LABEL: sdiv_i1:
39
40 ; NOT-R6: div $zero, $4, $5
41 ; NOT-R6: teq $5, $zero, 7
42 ; NOT-R6: mflo $[[T0:[0-9]+]]
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000043 ; FIXME: The andi/negu instructions are redundant since div is signed.
44 ; NOT-R6: andi $[[T0]], $[[T0]], 1
45 ; NOT-R6: negu $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000046
47 ; R6: div $[[T0:[0-9]+]], $4, $5
48 ; R6: teq $5, $zero, 7
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000049 ; FIXME: The andi/negu instructions are redundant since div is signed.
50 ; R6: andi $[[T0]], $[[T0]], 1
51 ; R6: negu $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000052
Zlatko Buljan58d6a952016-04-13 08:02:26 +000053 ; MMR3: div $zero, $4, $5
54 ; MMR3: teq $5, $zero, 7
55 ; MMR3: mflo $[[T0:[0-9]+]]
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000056 ; MMR3: andi16 $[[T0]], $[[T0]], 1
57 ; MMR3: li16 $[[T1:[0-9]+]], 0
58 ; MMR3: subu16 $2, $[[T1]], $[[T0]]
Zlatko Buljan58d6a952016-04-13 08:02:26 +000059
60 ; MMR6: div $[[T0:[0-9]+]], $4, $5
61 ; MMR6: teq $5, $zero, 7
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000062 ; MMR6: andi16 $[[T0]], $[[T0]], 1
63 ; MMR6: li16 $[[T1:[0-9]+]], 0
64 ; MMR6: subu16 $2, $[[T1]], $[[T0]]
Zlatko Buljan58d6a952016-04-13 08:02:26 +000065
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000066 %r = sdiv i1 %a, %b
67 ret i1 %r
68}
69
70define signext i8 @sdiv_i8(i8 signext %a, i8 signext %b) {
71entry:
72; ALL-LABEL: sdiv_i8:
73
74 ; NOT-R2-R6: div $zero, $4, $5
75 ; NOT-R2-R6: teq $5, $zero, 7
76 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
77 ; FIXME: The sll/sra instructions are redundant since div is signed.
78 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 24
79 ; NOT-R2-R6: sra $2, $[[T1]], 24
80
Daniel Sanders17793142015-02-18 16:24:50 +000081 ; R2-R5: div $zero, $4, $5
82 ; R2-R5: teq $5, $zero, 7
83 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000084 ; FIXME: This instruction is redundant.
Daniel Sanders17793142015-02-18 16:24:50 +000085 ; R2-R5: seb $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000086
87 ; R6: div $[[T0:[0-9]+]], $4, $5
88 ; R6: teq $5, $zero, 7
89 ; FIXME: This instruction is redundant.
90 ; R6: seb $2, $[[T0]]
91
Zlatko Buljan58d6a952016-04-13 08:02:26 +000092 ; MMR3: div $zero, $4, $5
93 ; MMR3: teq $5, $zero, 7
94 ; MMR3: mflo $[[T0:[0-9]+]]
95 ; MMR3: seb $2, $[[T0]]
96
97 ; MMR6: div $[[T0:[0-9]+]], $4, $5
98 ; MMR6: teq $5, $zero, 7
99 ; MMR6: seb $2, $[[T0]]
100
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000101 %r = sdiv i8 %a, %b
102 ret i8 %r
103}
104
105define signext i16 @sdiv_i16(i16 signext %a, i16 signext %b) {
106entry:
107; ALL-LABEL: sdiv_i16:
108
109 ; NOT-R2-R6: div $zero, $4, $5
110 ; NOT-R2-R6: teq $5, $zero, 7
111 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
112 ; FIXME: The sll/sra instructions are redundant since div is signed.
113 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 16
114 ; NOT-R2-R6: sra $2, $[[T1]], 16
115
Daniel Sanders17793142015-02-18 16:24:50 +0000116 ; R2-R5: div $zero, $4, $5
117 ; R2-R5: teq $5, $zero, 7
118 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000119 ; FIXME: This is instruction is redundant since div is signed.
Daniel Sanders17793142015-02-18 16:24:50 +0000120 ; R2-R5: seh $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000121
122 ; R6: div $[[T0:[0-9]+]], $4, $5
123 ; R6: teq $5, $zero, 7
124 ; FIXME: This is instruction is redundant since div is signed.
125 ; R6: seh $2, $[[T0]]
126
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000127 ; MMR3: div $zero, $4, $5
128 ; MMR3: teq $5, $zero, 7
129 ; MMR3: mflo $[[T0:[0-9]+]]
130 ; MMR3: seh $2, $[[T0]]
131
132 ; MMR6: div $[[T0:[0-9]+]], $4, $5
133 ; MMR6: teq $5, $zero, 7
134 ; MMR6: seh $2, $[[T0]]
135
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000136 %r = sdiv i16 %a, %b
137 ret i16 %r
138}
139
140define signext i32 @sdiv_i32(i32 signext %a, i32 signext %b) {
141entry:
142; ALL-LABEL: sdiv_i32:
143
144 ; NOT-R6: div $zero, $4, $5
145 ; NOT-R6: teq $5, $zero, 7
146 ; NOT-R6: mflo $2
147
148 ; R6: div $2, $4, $5
149 ; R6: teq $5, $zero, 7
150
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000151 ; MMR3: div $zero, $4, $5
152 ; MMR3: teq $5, $zero, 7
153 ; MMR3: mflo $2
154
155 ; MMR6: div $2, $4, $5
156 ; MMR6: teq $5, $zero, 7
157
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000158 %r = sdiv i32 %a, %b
159 ret i32 %r
160}
161
162define signext i64 @sdiv_i64(i64 signext %a, i64 signext %b) {
163entry:
164; ALL-LABEL: sdiv_i64:
165
166 ; GP32: lw $25, %call16(__divdi3)($gp)
167
168 ; GP64-NOT-R6: ddiv $zero, $4, $5
169 ; GP64-NOT-R6: teq $5, $zero, 7
170 ; GP64-NOT-R6: mflo $2
171
172 ; 64R6: ddiv $2, $4, $5
173 ; 64R6: teq $5, $zero, 7
174
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000175 ; MM32: lw $25, %call16(__divdi3)($2)
176
177 ; MM64: ddiv $2, $4, $5
178 ; MM64: teq $5, $zero, 7
179
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000180 %r = sdiv i64 %a, %b
181 ret i64 %r
182}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000183
184define signext i128 @sdiv_i128(i128 signext %a, i128 signext %b) {
185entry:
186 ; ALL-LABEL: sdiv_i128:
187
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000188 ; GP32: lw $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000189
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000190 ; GP64-NOT-R6: ld $25, %call16(__divti3)($gp)
191 ; 64R6: ld $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000192
Simon Dardisf1148202016-08-24 13:00:47 +0000193 ; MM32: lw $25, %call16(__divti3)($16)
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000194
195 ; MM64: ld $25, %call16(__divti3)($2)
196
197 %r = sdiv i128 %a, %b
198 ret i128 %r
199}