blob: f6eefc7a7fdfe2864ce8da15fff219b3f718e6b2 [file] [log] [blame]
Petar Jovanovice578e972016-04-11 15:24:23 +00001; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +00002; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
3; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00004; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +00005; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
6; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00007; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +00008; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
9; RUN: -check-prefix=R2-R5 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +000010; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000011; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
12; RUN: -check-prefix=R2-R5 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +000013; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000014; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
15; RUN: -check-prefix=R2-R5 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +000016; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000017; RUN: -check-prefix=ALL -check-prefix=R6 \
18; RUN: -check-prefix=GP32
19
Petar Jovanovice578e972016-04-11 15:24:23 +000020; RUN: llc < %s -march=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000021; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
22; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000023; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000024; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
25; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000026; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000027; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
28; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000029; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000030; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
31; RUN: -check-prefix=R2-R5 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000032; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000033; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
34; RUN: -check-prefix=R2-R5 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000035; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000036; RUN: -check-prefix=ALL -check-prefix=NOT-R6 \
37; RUN: -check-prefix=R2-R5 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000038; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000039; RUN: -check-prefix=ALL -check-prefix=R6 \
40; RUN: -check-prefix=64R6
41
Zlatko Buljan58d6a952016-04-13 08:02:26 +000042; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000043; RUN: -check-prefix=ALL -check-prefix=MMR3 -check-prefix=MM32
Zlatko Buljan58d6a952016-04-13 08:02:26 +000044; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000045; RUN: -check-prefix=ALL -check-prefix=MMR6 -check-prefix=MM32
Daniel Sandersde393322016-06-23 12:42:53 +000046; RUN: llc < %s -march=mips -mcpu=mips64r6 -mattr=+micromips -target-abi n64 -relocation-model=pic | FileCheck %s \
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000047; RUN: -check-prefix=ALL -check-prefix=MMR6 -check-prefix=MM64
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000048
49define signext i1 @sdiv_i1(i1 signext %a, i1 signext %b) {
50entry:
51; ALL-LABEL: sdiv_i1:
52
53 ; NOT-R6: div $zero, $4, $5
54 ; NOT-R6: teq $5, $zero, 7
55 ; NOT-R6: mflo $[[T0:[0-9]+]]
56 ; FIXME: The sll/sra instructions are redundant since div is signed.
57 ; NOT-R6: sll $[[T1:[0-9]+]], $[[T0]], 31
58 ; NOT-R6: sra $2, $[[T1]], 31
59
60 ; R6: div $[[T0:[0-9]+]], $4, $5
61 ; R6: teq $5, $zero, 7
62 ; FIXME: The sll/sra instructions are redundant since div is signed.
63 ; R6: sll $[[T1:[0-9]+]], $[[T0]], 31
64 ; R6: sra $2, $[[T1]], 31
65
Zlatko Buljan58d6a952016-04-13 08:02:26 +000066 ; MMR3: div $zero, $4, $5
67 ; MMR3: teq $5, $zero, 7
68 ; MMR3: mflo $[[T0:[0-9]+]]
69 ; MMR3: sll $[[T1:[0-9]+]], $[[T0]], 31
70 ; MMR3: sra $2, $[[T1]], 31
71
72 ; MMR6: div $[[T0:[0-9]+]], $4, $5
73 ; MMR6: teq $5, $zero, 7
74 ; MMR6: sll $[[T1:[0-9]+]], $[[T0]], 31
75 ; MMR6: sra $2, $[[T1]], 31
76
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000077 %r = sdiv i1 %a, %b
78 ret i1 %r
79}
80
81define signext i8 @sdiv_i8(i8 signext %a, i8 signext %b) {
82entry:
83; ALL-LABEL: sdiv_i8:
84
85 ; NOT-R2-R6: div $zero, $4, $5
86 ; NOT-R2-R6: teq $5, $zero, 7
87 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
88 ; FIXME: The sll/sra instructions are redundant since div is signed.
89 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 24
90 ; NOT-R2-R6: sra $2, $[[T1]], 24
91
Daniel Sanders17793142015-02-18 16:24:50 +000092 ; R2-R5: div $zero, $4, $5
93 ; R2-R5: teq $5, $zero, 7
94 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000095 ; FIXME: This instruction is redundant.
Daniel Sanders17793142015-02-18 16:24:50 +000096 ; R2-R5: seb $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000097
98 ; R6: div $[[T0:[0-9]+]], $4, $5
99 ; R6: teq $5, $zero, 7
100 ; FIXME: This instruction is redundant.
101 ; R6: seb $2, $[[T0]]
102
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000103 ; MMR3: div $zero, $4, $5
104 ; MMR3: teq $5, $zero, 7
105 ; MMR3: mflo $[[T0:[0-9]+]]
106 ; MMR3: seb $2, $[[T0]]
107
108 ; MMR6: div $[[T0:[0-9]+]], $4, $5
109 ; MMR6: teq $5, $zero, 7
110 ; MMR6: seb $2, $[[T0]]
111
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000112 %r = sdiv i8 %a, %b
113 ret i8 %r
114}
115
116define signext i16 @sdiv_i16(i16 signext %a, i16 signext %b) {
117entry:
118; ALL-LABEL: sdiv_i16:
119
120 ; NOT-R2-R6: div $zero, $4, $5
121 ; NOT-R2-R6: teq $5, $zero, 7
122 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
123 ; FIXME: The sll/sra instructions are redundant since div is signed.
124 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 16
125 ; NOT-R2-R6: sra $2, $[[T1]], 16
126
Daniel Sanders17793142015-02-18 16:24:50 +0000127 ; R2-R5: div $zero, $4, $5
128 ; R2-R5: teq $5, $zero, 7
129 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000130 ; FIXME: This is instruction is redundant since div is signed.
Daniel Sanders17793142015-02-18 16:24:50 +0000131 ; R2-R5: seh $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000132
133 ; R6: div $[[T0:[0-9]+]], $4, $5
134 ; R6: teq $5, $zero, 7
135 ; FIXME: This is instruction is redundant since div is signed.
136 ; R6: seh $2, $[[T0]]
137
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000138 ; MMR3: div $zero, $4, $5
139 ; MMR3: teq $5, $zero, 7
140 ; MMR3: mflo $[[T0:[0-9]+]]
141 ; MMR3: seh $2, $[[T0]]
142
143 ; MMR6: div $[[T0:[0-9]+]], $4, $5
144 ; MMR6: teq $5, $zero, 7
145 ; MMR6: seh $2, $[[T0]]
146
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000147 %r = sdiv i16 %a, %b
148 ret i16 %r
149}
150
151define signext i32 @sdiv_i32(i32 signext %a, i32 signext %b) {
152entry:
153; ALL-LABEL: sdiv_i32:
154
155 ; NOT-R6: div $zero, $4, $5
156 ; NOT-R6: teq $5, $zero, 7
157 ; NOT-R6: mflo $2
158
159 ; R6: div $2, $4, $5
160 ; R6: teq $5, $zero, 7
161
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000162 ; MMR3: div $zero, $4, $5
163 ; MMR3: teq $5, $zero, 7
164 ; MMR3: mflo $2
165
166 ; MMR6: div $2, $4, $5
167 ; MMR6: teq $5, $zero, 7
168
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000169 %r = sdiv i32 %a, %b
170 ret i32 %r
171}
172
173define signext i64 @sdiv_i64(i64 signext %a, i64 signext %b) {
174entry:
175; ALL-LABEL: sdiv_i64:
176
177 ; GP32: lw $25, %call16(__divdi3)($gp)
178
179 ; GP64-NOT-R6: ddiv $zero, $4, $5
180 ; GP64-NOT-R6: teq $5, $zero, 7
181 ; GP64-NOT-R6: mflo $2
182
183 ; 64R6: ddiv $2, $4, $5
184 ; 64R6: teq $5, $zero, 7
185
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000186 ; MM32: lw $25, %call16(__divdi3)($2)
187
188 ; MM64: ddiv $2, $4, $5
189 ; MM64: teq $5, $zero, 7
190
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000191 %r = sdiv i64 %a, %b
192 ret i64 %r
193}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000194
195define signext i128 @sdiv_i128(i128 signext %a, i128 signext %b) {
196entry:
197 ; ALL-LABEL: sdiv_i128:
198
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000199 ; GP32: lw $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000200
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000201 ; GP64-NOT-R6: ld $25, %call16(__divti3)($gp)
202 ; 64R6: ld $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000203
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000204 ; MM32: lw $25, %call16(__divti3)($2)
205
206 ; MM64: ld $25, %call16(__divti3)($2)
207
208 %r = sdiv i128 %a, %b
209 ret i128 %r
210}