blob: 2d2b8ff12c04d72f32886e5b45afaf3a00bf269c [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]+]]
43 ; FIXME: The sll/sra instructions are redundant since div is signed.
44 ; NOT-R6: sll $[[T1:[0-9]+]], $[[T0]], 31
45 ; NOT-R6: sra $2, $[[T1]], 31
46
47 ; R6: div $[[T0:[0-9]+]], $4, $5
48 ; R6: teq $5, $zero, 7
49 ; FIXME: The sll/sra instructions are redundant since div is signed.
50 ; R6: sll $[[T1:[0-9]+]], $[[T0]], 31
51 ; R6: sra $2, $[[T1]], 31
52
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]+]]
56 ; MMR3: sll $[[T1:[0-9]+]], $[[T0]], 31
57 ; MMR3: sra $2, $[[T1]], 31
58
59 ; MMR6: div $[[T0:[0-9]+]], $4, $5
60 ; MMR6: teq $5, $zero, 7
61 ; MMR6: sll $[[T1:[0-9]+]], $[[T0]], 31
62 ; MMR6: sra $2, $[[T1]], 31
63
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000064 %r = sdiv i1 %a, %b
65 ret i1 %r
66}
67
68define signext i8 @sdiv_i8(i8 signext %a, i8 signext %b) {
69entry:
70; ALL-LABEL: sdiv_i8:
71
72 ; NOT-R2-R6: div $zero, $4, $5
73 ; NOT-R2-R6: teq $5, $zero, 7
74 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
75 ; FIXME: The sll/sra instructions are redundant since div is signed.
76 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 24
77 ; NOT-R2-R6: sra $2, $[[T1]], 24
78
Daniel Sanders17793142015-02-18 16:24:50 +000079 ; R2-R5: div $zero, $4, $5
80 ; R2-R5: teq $5, $zero, 7
81 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000082 ; FIXME: This instruction is redundant.
Daniel Sanders17793142015-02-18 16:24:50 +000083 ; R2-R5: seb $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000084
85 ; R6: div $[[T0:[0-9]+]], $4, $5
86 ; R6: teq $5, $zero, 7
87 ; FIXME: This instruction is redundant.
88 ; R6: seb $2, $[[T0]]
89
Zlatko Buljan58d6a952016-04-13 08:02:26 +000090 ; MMR3: div $zero, $4, $5
91 ; MMR3: teq $5, $zero, 7
92 ; MMR3: mflo $[[T0:[0-9]+]]
93 ; MMR3: seb $2, $[[T0]]
94
95 ; MMR6: div $[[T0:[0-9]+]], $4, $5
96 ; MMR6: teq $5, $zero, 7
97 ; MMR6: seb $2, $[[T0]]
98
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000099 %r = sdiv i8 %a, %b
100 ret i8 %r
101}
102
103define signext i16 @sdiv_i16(i16 signext %a, i16 signext %b) {
104entry:
105; ALL-LABEL: sdiv_i16:
106
107 ; NOT-R2-R6: div $zero, $4, $5
108 ; NOT-R2-R6: teq $5, $zero, 7
109 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
110 ; FIXME: The sll/sra instructions are redundant since div is signed.
111 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 16
112 ; NOT-R2-R6: sra $2, $[[T1]], 16
113
Daniel Sanders17793142015-02-18 16:24:50 +0000114 ; R2-R5: div $zero, $4, $5
115 ; R2-R5: teq $5, $zero, 7
116 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000117 ; FIXME: This is instruction is redundant since div is signed.
Daniel Sanders17793142015-02-18 16:24:50 +0000118 ; R2-R5: seh $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000119
120 ; R6: div $[[T0:[0-9]+]], $4, $5
121 ; R6: teq $5, $zero, 7
122 ; FIXME: This is instruction is redundant since div is signed.
123 ; R6: seh $2, $[[T0]]
124
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000125 ; MMR3: div $zero, $4, $5
126 ; MMR3: teq $5, $zero, 7
127 ; MMR3: mflo $[[T0:[0-9]+]]
128 ; MMR3: seh $2, $[[T0]]
129
130 ; MMR6: div $[[T0:[0-9]+]], $4, $5
131 ; MMR6: teq $5, $zero, 7
132 ; MMR6: seh $2, $[[T0]]
133
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000134 %r = sdiv i16 %a, %b
135 ret i16 %r
136}
137
138define signext i32 @sdiv_i32(i32 signext %a, i32 signext %b) {
139entry:
140; ALL-LABEL: sdiv_i32:
141
142 ; NOT-R6: div $zero, $4, $5
143 ; NOT-R6: teq $5, $zero, 7
144 ; NOT-R6: mflo $2
145
146 ; R6: div $2, $4, $5
147 ; R6: teq $5, $zero, 7
148
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000149 ; MMR3: div $zero, $4, $5
150 ; MMR3: teq $5, $zero, 7
151 ; MMR3: mflo $2
152
153 ; MMR6: div $2, $4, $5
154 ; MMR6: teq $5, $zero, 7
155
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000156 %r = sdiv i32 %a, %b
157 ret i32 %r
158}
159
160define signext i64 @sdiv_i64(i64 signext %a, i64 signext %b) {
161entry:
162; ALL-LABEL: sdiv_i64:
163
164 ; GP32: lw $25, %call16(__divdi3)($gp)
165
166 ; GP64-NOT-R6: ddiv $zero, $4, $5
167 ; GP64-NOT-R6: teq $5, $zero, 7
168 ; GP64-NOT-R6: mflo $2
169
170 ; 64R6: ddiv $2, $4, $5
171 ; 64R6: teq $5, $zero, 7
172
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000173 ; MM32: lw $25, %call16(__divdi3)($2)
174
175 ; MM64: ddiv $2, $4, $5
176 ; MM64: teq $5, $zero, 7
177
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000178 %r = sdiv i64 %a, %b
179 ret i64 %r
180}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000181
182define signext i128 @sdiv_i128(i128 signext %a, i128 signext %b) {
183entry:
184 ; ALL-LABEL: sdiv_i128:
185
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000186 ; GP32: lw $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000187
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000188 ; GP64-NOT-R6: ld $25, %call16(__divti3)($gp)
189 ; 64R6: ld $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000190
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000191 ; MM32: lw $25, %call16(__divti3)($2)
192
193 ; MM64: ld $25, %call16(__divti3)($2)
194
195 %r = sdiv i128 %a, %b
196 ret i128 %r
197}