1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
3 define i32 @mul_i32(i32 %x, i32 %y) {
4 ; MIPS32-LABEL: mul_i32:
5 ; MIPS32: # %bb.0: # %entry
6 ; MIPS32-NEXT: mul $2, $4, $5
14 define signext i8 @mul_i8_sext(i8 signext %a, i8 signext %b) {
15 ; MIPS32-LABEL: mul_i8_sext:
16 ; MIPS32: # %bb.0: # %entry
17 ; MIPS32-NEXT: mul $1, $5, $4
18 ; MIPS32-NEXT: sll $1, $1, 24
19 ; MIPS32-NEXT: sra $2, $1, 24
27 define zeroext i8 @mul_i8_zext(i8 zeroext %a, i8 zeroext %b) {
28 ; MIPS32-LABEL: mul_i8_zext:
29 ; MIPS32: # %bb.0: # %entry
30 ; MIPS32-NEXT: mul $1, $5, $4
31 ; MIPS32-NEXT: ori $2, $zero, 255
32 ; MIPS32-NEXT: and $2, $1, $2
40 define i8 @mul_i8_aext(i8 %a, i8 %b) {
41 ; MIPS32-LABEL: mul_i8_aext:
42 ; MIPS32: # %bb.0: # %entry
43 ; MIPS32-NEXT: mul $2, $5, $4
51 define signext i16 @mul_i16_sext(i16 signext %a, i16 signext %b) {
52 ; MIPS32-LABEL: mul_i16_sext:
53 ; MIPS32: # %bb.0: # %entry
54 ; MIPS32-NEXT: mul $1, $5, $4
55 ; MIPS32-NEXT: sll $1, $1, 16
56 ; MIPS32-NEXT: sra $2, $1, 16
64 define zeroext i16 @mul_i16_zext(i16 zeroext %a, i16 zeroext %b) {
65 ; MIPS32-LABEL: mul_i16_zext:
66 ; MIPS32: # %bb.0: # %entry
67 ; MIPS32-NEXT: mul $1, $5, $4
68 ; MIPS32-NEXT: ori $2, $zero, 65535
69 ; MIPS32-NEXT: and $2, $1, $2
77 define i16 @mul_i16_aext(i16 %a, i16 %b) {
78 ; MIPS32-LABEL: mul_i16_aext:
79 ; MIPS32: # %bb.0: # %entry
80 ; MIPS32-NEXT: mul $2, $5, $4
88 define i64 @mul_i64(i64 %a, i64 %b) {
89 ; MIPS32-LABEL: mul_i64:
90 ; MIPS32: # %bb.0: # %entry
91 ; MIPS32-NEXT: mul $2, $6, $4
92 ; MIPS32-NEXT: mul $1, $7, $4
93 ; MIPS32-NEXT: mul $3, $6, $5
94 ; MIPS32-NEXT: multu $6, $4
95 ; MIPS32-NEXT: mfhi $4
96 ; MIPS32-NEXT: addu $1, $1, $3
97 ; MIPS32-NEXT: addu $3, $1, $4
101 %mul = mul i64 %b, %a
105 define i128 @mul_i128(i128 %a, i128 %b) {
106 ; MIPS32-LABEL: mul_i128:
107 ; MIPS32: # %bb.0: # %entry
108 ; MIPS32-NEXT: addiu $1, $sp, 16
109 ; MIPS32-NEXT: lw $1, 0($1)
110 ; MIPS32-NEXT: addiu $2, $sp, 20
111 ; MIPS32-NEXT: lw $2, 0($2)
112 ; MIPS32-NEXT: addiu $3, $sp, 24
113 ; MIPS32-NEXT: lw $3, 0($3)
114 ; MIPS32-NEXT: addiu $8, $sp, 28
115 ; MIPS32-NEXT: lw $8, 0($8)
116 ; MIPS32-NEXT: mul $9, $1, $4
117 ; MIPS32-NEXT: mul $10, $2, $4
118 ; MIPS32-NEXT: mul $11, $1, $5
119 ; MIPS32-NEXT: multu $1, $4
120 ; MIPS32-NEXT: mfhi $12
121 ; MIPS32-NEXT: addu $10, $10, $11
122 ; MIPS32-NEXT: sltu $11, $10, $11
123 ; MIPS32-NEXT: ori $13, $zero, 1
124 ; MIPS32-NEXT: and $11, $11, $13
125 ; MIPS32-NEXT: addu $10, $10, $12
126 ; MIPS32-NEXT: sltu $12, $10, $12
127 ; MIPS32-NEXT: and $12, $12, $13
128 ; MIPS32-NEXT: addu $11, $11, $12
129 ; MIPS32-NEXT: mul $12, $3, $4
130 ; MIPS32-NEXT: mul $14, $2, $5
131 ; MIPS32-NEXT: mul $15, $1, $6
132 ; MIPS32-NEXT: multu $2, $4
133 ; MIPS32-NEXT: mfhi $24
134 ; MIPS32-NEXT: multu $1, $5
135 ; MIPS32-NEXT: mfhi $25
136 ; MIPS32-NEXT: addu $12, $12, $14
137 ; MIPS32-NEXT: sltu $14, $12, $14
138 ; MIPS32-NEXT: and $14, $14, $13
139 ; MIPS32-NEXT: addu $12, $12, $15
140 ; MIPS32-NEXT: sltu $15, $12, $15
141 ; MIPS32-NEXT: and $15, $15, $13
142 ; MIPS32-NEXT: addu $14, $14, $15
143 ; MIPS32-NEXT: addu $12, $12, $24
144 ; MIPS32-NEXT: sltu $15, $12, $24
145 ; MIPS32-NEXT: and $15, $15, $13
146 ; MIPS32-NEXT: addu $14, $14, $15
147 ; MIPS32-NEXT: addu $12, $12, $25
148 ; MIPS32-NEXT: sltu $15, $12, $25
149 ; MIPS32-NEXT: and $15, $15, $13
150 ; MIPS32-NEXT: addu $14, $14, $15
151 ; MIPS32-NEXT: addu $12, $12, $11
152 ; MIPS32-NEXT: sltu $11, $12, $11
153 ; MIPS32-NEXT: and $11, $11, $13
154 ; MIPS32-NEXT: addu $11, $14, $11
155 ; MIPS32-NEXT: mul $8, $8, $4
156 ; MIPS32-NEXT: mul $13, $3, $5
157 ; MIPS32-NEXT: mul $14, $2, $6
158 ; MIPS32-NEXT: mul $7, $1, $7
159 ; MIPS32-NEXT: multu $3, $4
160 ; MIPS32-NEXT: mfhi $3
161 ; MIPS32-NEXT: multu $2, $5
162 ; MIPS32-NEXT: mfhi $2
163 ; MIPS32-NEXT: multu $1, $6
164 ; MIPS32-NEXT: mfhi $1
165 ; MIPS32-NEXT: addu $4, $8, $13
166 ; MIPS32-NEXT: addu $4, $4, $14
167 ; MIPS32-NEXT: addu $4, $4, $7
168 ; MIPS32-NEXT: addu $3, $4, $3
169 ; MIPS32-NEXT: addu $2, $3, $2
170 ; MIPS32-NEXT: addu $1, $2, $1
171 ; MIPS32-NEXT: addu $5, $1, $11
172 ; MIPS32-NEXT: move $2, $9
173 ; MIPS32-NEXT: move $3, $10
174 ; MIPS32-NEXT: move $4, $12
175 ; MIPS32-NEXT: jr $ra
178 %mul = mul i128 %b, %a
182 declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32)
183 define void @umul_with_overflow(i32 %lhs, i32 %rhs, i32* %pmul, i1* %pcarry_flag) {
184 ; MIPS32-LABEL: umul_with_overflow:
186 ; MIPS32-NEXT: mul $1, $4, $5
187 ; MIPS32-NEXT: multu $4, $5
188 ; MIPS32-NEXT: mfhi $2
189 ; MIPS32-NEXT: sltu $2, $zero, $2
190 ; MIPS32-NEXT: ori $3, $zero, 1
191 ; MIPS32-NEXT: and $2, $2, $3
192 ; MIPS32-NEXT: sb $2, 0($7)
193 ; MIPS32-NEXT: sw $1, 0($6)
194 ; MIPS32-NEXT: jr $ra
196 %res = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %lhs, i32 %rhs)
197 %carry_flag = extractvalue { i32, i1 } %res, 1
198 %mul = extractvalue { i32, i1 } %res, 0
199 store i1 %carry_flag, i1* %pcarry_flag
200 store i32 %mul, i32* %pmul