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 @add_i32(i32 %x, i32 %y) {
4 ; MIPS32-LABEL: add_i32:
5 ; MIPS32: # %bb.0: # %entry
6 ; MIPS32-NEXT: addu $2, $4, $5
14 define signext i8 @add_i8_sext(i8 signext %a, i8 signext %b) {
15 ; MIPS32-LABEL: add_i8_sext:
16 ; MIPS32: # %bb.0: # %entry
17 ; MIPS32-NEXT: addu $1, $5, $4
18 ; MIPS32-NEXT: sll $1, $1, 24
19 ; MIPS32-NEXT: sra $2, $1, 24
27 define zeroext i8 @add_i8_zext(i8 zeroext %a, i8 zeroext %b) {
28 ; MIPS32-LABEL: add_i8_zext:
29 ; MIPS32: # %bb.0: # %entry
30 ; MIPS32-NEXT: addu $1, $5, $4
31 ; MIPS32-NEXT: ori $2, $zero, 255
32 ; MIPS32-NEXT: and $2, $1, $2
40 define i8 @add_i8_aext(i8 %a, i8 %b) {
41 ; MIPS32-LABEL: add_i8_aext:
42 ; MIPS32: # %bb.0: # %entry
43 ; MIPS32-NEXT: addu $2, $5, $4
51 define signext i16 @add_i16_sext(i16 signext %a, i16 signext %b) {
52 ; MIPS32-LABEL: add_i16_sext:
53 ; MIPS32: # %bb.0: # %entry
54 ; MIPS32-NEXT: addu $1, $5, $4
55 ; MIPS32-NEXT: sll $1, $1, 16
56 ; MIPS32-NEXT: sra $2, $1, 16
64 define zeroext i16 @add_i16_zext(i16 zeroext %a, i16 zeroext %b) {
65 ; MIPS32-LABEL: add_i16_zext:
66 ; MIPS32: # %bb.0: # %entry
67 ; MIPS32-NEXT: addu $1, $5, $4
68 ; MIPS32-NEXT: ori $2, $zero, 65535
69 ; MIPS32-NEXT: and $2, $1, $2
77 define i16 @add_i16_aext(i16 %a, i16 %b) {
78 ; MIPS32-LABEL: add_i16_aext:
79 ; MIPS32: # %bb.0: # %entry
80 ; MIPS32-NEXT: addu $2, $5, $4
88 define i64 @add_i64(i64 %a, i64 %b) {
89 ; MIPS32-LABEL: add_i64:
90 ; MIPS32: # %bb.0: # %entry
91 ; MIPS32-NEXT: ori $1, $zero, 0
92 ; MIPS32-NEXT: addu $2, $6, $4
93 ; MIPS32-NEXT: ori $3, $zero, 1
94 ; MIPS32-NEXT: and $1, $1, $3
95 ; MIPS32-NEXT: addu $1, $2, $1
96 ; MIPS32-NEXT: sltu $2, $1, $6
97 ; MIPS32-NEXT: addu $4, $7, $5
98 ; MIPS32-NEXT: and $2, $2, $3
99 ; MIPS32-NEXT: addu $3, $4, $2
100 ; MIPS32-NEXT: move $2, $1
101 ; MIPS32-NEXT: jr $ra
104 %add = add i64 %b, %a
108 define i128 @add_i128(i128 %a, i128 %b) {
109 ; MIPS32-LABEL: add_i128:
110 ; MIPS32: # %bb.0: # %entry
111 ; MIPS32-NEXT: addiu $sp, $sp, -8
112 ; MIPS32-NEXT: .cfi_def_cfa_offset 8
113 ; MIPS32-NEXT: addiu $1, $sp, 24
114 ; MIPS32-NEXT: lw $1, 0($1)
115 ; MIPS32-NEXT: addiu $2, $sp, 28
116 ; MIPS32-NEXT: lw $2, 0($2)
117 ; MIPS32-NEXT: addiu $3, $sp, 32
118 ; MIPS32-NEXT: lw $3, 0($3)
119 ; MIPS32-NEXT: addiu $8, $sp, 36
120 ; MIPS32-NEXT: lw $8, 0($8)
121 ; MIPS32-NEXT: ori $9, $zero, 0
122 ; MIPS32-NEXT: addu $4, $1, $4
123 ; MIPS32-NEXT: ori $10, $zero, 1
124 ; MIPS32-NEXT: and $9, $9, $10
125 ; MIPS32-NEXT: addu $4, $4, $9
126 ; MIPS32-NEXT: sltu $1, $4, $1
127 ; MIPS32-NEXT: addu $5, $2, $5
128 ; MIPS32-NEXT: and $1, $1, $10
129 ; MIPS32-NEXT: addu $1, $5, $1
130 ; MIPS32-NEXT: sltu $2, $1, $2
131 ; MIPS32-NEXT: addu $5, $3, $6
132 ; MIPS32-NEXT: and $2, $2, $10
133 ; MIPS32-NEXT: addu $2, $5, $2
134 ; MIPS32-NEXT: sltu $3, $2, $3
135 ; MIPS32-NEXT: addu $5, $8, $7
136 ; MIPS32-NEXT: and $3, $3, $10
137 ; MIPS32-NEXT: addu $5, $5, $3
138 ; MIPS32-NEXT: sw $2, 4($sp) # 4-byte Folded Spill
139 ; MIPS32-NEXT: move $2, $4
140 ; MIPS32-NEXT: move $3, $1
141 ; MIPS32-NEXT: lw $4, 4($sp) # 4-byte Folded Reload
142 ; MIPS32-NEXT: addiu $sp, $sp, 8
143 ; MIPS32-NEXT: jr $ra
146 %add = add i128 %b, %a
150 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32)
151 define void @uadd_with_overflow(i32 %lhs, i32 %rhs, i32* %padd, i1* %pcarry_flag) {
152 ; MIPS32-LABEL: uadd_with_overflow:
154 ; MIPS32-NEXT: addu $1, $4, $5
155 ; MIPS32-NEXT: sltu $2, $1, $5
156 ; MIPS32-NEXT: ori $3, $zero, 1
157 ; MIPS32-NEXT: and $2, $2, $3
158 ; MIPS32-NEXT: sb $2, 0($7)
159 ; MIPS32-NEXT: sw $1, 0($6)
160 ; MIPS32-NEXT: jr $ra
162 %res = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %lhs, i32 %rhs)
163 %carry_flag = extractvalue { i32, i1 } %res, 1
164 %add = extractvalue { i32, i1 } %res, 0
165 store i1 %carry_flag, i1* %pcarry_flag
166 store i32 %add, i32* %padd