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: addu $1, $6, $4
92 ; MIPS32-NEXT: sltu $2, $1, $4
93 ; MIPS32-NEXT: addu $3, $7, $5
94 ; MIPS32-NEXT: ori $4, $zero, 1
95 ; MIPS32-NEXT: and $2, $2, $4
96 ; MIPS32-NEXT: addu $3, $3, $2
97 ; MIPS32-NEXT: move $2, $1
101 %add = add i64 %b, %a
105 define i128 @add_i128(i128 %a, i128 %b) {
106 ; MIPS32-LABEL: add_i128:
107 ; MIPS32: # %bb.0: # %entry
108 ; MIPS32-NEXT: addiu $sp, $sp, -8
109 ; MIPS32-NEXT: .cfi_def_cfa_offset 8
110 ; MIPS32-NEXT: addiu $1, $sp, 24
111 ; MIPS32-NEXT: lw $1, 0($1)
112 ; MIPS32-NEXT: addiu $2, $sp, 28
113 ; MIPS32-NEXT: lw $2, 0($2)
114 ; MIPS32-NEXT: addiu $3, $sp, 32
115 ; MIPS32-NEXT: lw $3, 0($3)
116 ; MIPS32-NEXT: addiu $8, $sp, 36
117 ; MIPS32-NEXT: lw $8, 0($8)
118 ; MIPS32-NEXT: addu $1, $1, $4
119 ; MIPS32-NEXT: sltu $4, $1, $4
120 ; MIPS32-NEXT: addu $5, $2, $5
121 ; MIPS32-NEXT: ori $9, $zero, 1
122 ; MIPS32-NEXT: and $4, $4, $9
123 ; MIPS32-NEXT: addu $4, $5, $4
124 ; MIPS32-NEXT: sltu $2, $4, $2
125 ; MIPS32-NEXT: addu $5, $3, $6
126 ; MIPS32-NEXT: and $2, $2, $9
127 ; MIPS32-NEXT: addu $2, $5, $2
128 ; MIPS32-NEXT: sltu $3, $2, $3
129 ; MIPS32-NEXT: addu $5, $8, $7
130 ; MIPS32-NEXT: and $3, $3, $9
131 ; MIPS32-NEXT: addu $5, $5, $3
132 ; MIPS32-NEXT: sw $2, 4($sp) # 4-byte Folded Spill
133 ; MIPS32-NEXT: move $2, $1
134 ; MIPS32-NEXT: move $3, $4
135 ; MIPS32-NEXT: lw $4, 4($sp) # 4-byte Folded Reload
136 ; MIPS32-NEXT: addiu $sp, $sp, 8
137 ; MIPS32-NEXT: jr $ra
140 %add = add i128 %b, %a
144 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32)
145 define void @uadd_with_overflow(i32 %lhs, i32 %rhs, i32* %padd, i1* %pcarry_flag) {
146 ; MIPS32-LABEL: uadd_with_overflow:
148 ; MIPS32-NEXT: addu $1, $4, $5
149 ; MIPS32-NEXT: sltu $2, $1, $5
150 ; MIPS32-NEXT: ori $3, $zero, 1
151 ; MIPS32-NEXT: and $2, $2, $3
152 ; MIPS32-NEXT: sb $2, 0($7)
153 ; MIPS32-NEXT: sw $1, 0($6)
154 ; MIPS32-NEXT: jr $ra
156 %res = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %lhs, i32 %rhs)
157 %carry_flag = extractvalue { i32, i1 } %res, 1
158 %add = extractvalue { i32, i1 } %res, 0
159 store i1 %carry_flag, i1* %pcarry_flag
160 store i32 %add, i32* %padd