blob: c6456c1274fb78a11d1975133c4cf8f391ad8a56 [file] [log] [blame]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00001; RUN: llc < %s -march=mips -mcpu=mips2 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +00002; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP32 -check-prefix=GP32-NOT-MM \
3; RUN: -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00004; RUN: llc < %s -march=mips -mcpu=mips32 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +00005; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP32 -check-prefix=GP32-NOT-MM \
6; RUN: -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00007; RUN: llc < %s -march=mips -mcpu=mips32r2 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +00008; RUN: -check-prefix=R2-R6 -check-prefix=GP32 -check-prefix=GP32-NOT-MM \
9; RUN: -check-prefix=NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +000010; RUN: llc < %s -march=mips -mcpu=mips32r3 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000011; RUN: -check-prefix=R2-R6 -check-prefix=GP32 -check-prefix=GP32-NOT-MM \
12; RUN: -check-prefix=NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +000013; RUN: llc < %s -march=mips -mcpu=mips32r5 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000014; RUN: -check-prefix=R2-R6 -check-prefix=GP32 -check-prefix=GP32-NOT-MM \
15; RUN: -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000016; RUN: llc < %s -march=mips -mcpu=mips32r6 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000017; RUN: -check-prefix=R2-R6 -check-prefix=GP32 -check-prefix=GP32-NOT-MM \
18; RUN: -check-prefix=NOT-MM
19; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips | FileCheck %s \
20; RUN: -check-prefix=GP32-MM -check-prefix=GP32 -check-prefix=MM
21; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips | FileCheck %s \
22; RUN: -check-prefix=GP32-MM -check-prefix=GP32 -check-prefix=MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000023; RUN: llc < %s -march=mips64 -mcpu=mips3 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000024; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000025; RUN: llc < %s -march=mips64 -mcpu=mips4 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000026; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000027; RUN: llc < %s -march=mips64 -mcpu=mips64 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000028; RUN: -check-prefix=NOT-R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000029; RUN: llc < %s -march=mips64 -mcpu=mips64r2 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000030; RUN: -check-prefix=R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +000031; RUN: llc < %s -march=mips64 -mcpu=mips64r3 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000032; RUN: -check-prefix=R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +000033; RUN: llc < %s -march=mips64 -mcpu=mips64r5 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000034; RUN: -check-prefix=R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000035; RUN: llc < %s -march=mips64 -mcpu=mips64r6 | FileCheck %s \
Zlatko Buljande0bbe62016-04-27 11:31:44 +000036; RUN: -check-prefix=R2-R6 -check-prefix=GP64 -check-prefix=NOT-MM
37; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -mattr=+micromips | FileCheck %s \
38; RUN: -check-prefix=GP64 -check-prefix=MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000039
40define signext i1 @sub_i1(i1 signext %a, i1 signext %b) {
41entry:
42; ALL-LABEL: sub_i1:
43
Zlatko Buljande0bbe62016-04-27 11:31:44 +000044 ; NOT-MM: subu $[[T0:[0-9]+]], $4, $5
45 ; NOT-MM: sll $[[T0]], $[[T0]], 31
46 ; NOT-MM: sra $2, $[[T0]], 31
47
48 ; MM: subu16 $[[T0:[0-9]+]], $4, $5
49 ; MM: sll $[[T1:[0-9]+]], $[[T0]], 31
50 ; MM: sra $[[T0]], $[[T1]], 31
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000051
52 %r = sub i1 %a, %b
53 ret i1 %r
54}
55
56define signext i8 @sub_i8(i8 signext %a, i8 signext %b) {
57entry:
58; ALL-LABEL: sub_i8:
59
60 ; NOT-R2-R6: subu $[[T0:[0-9]+]], $4, $5
61 ; NOT-R2-R6: sll $[[T0]], $[[T0]], 24
62 ; NOT-R2-R6: sra $2, $[[T0]], 24
63
64 ; R2-R6: subu $[[T0:[0-9]+]], $4, $5
65 ; R2-R6: seb $2, $[[T0:[0-9]+]]
66
Zlatko Buljande0bbe62016-04-27 11:31:44 +000067 ; MM: subu16 $[[T0:[0-9]+]], $4, $5
68 ; MM: seb $[[T0]], $[[T0]]
69
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000070 %r = sub i8 %a, %b
71 ret i8 %r
72}
73
74define signext i16 @sub_i16(i16 signext %a, i16 signext %b) {
75entry:
76; ALL-LABEL: sub_i16:
77
78 ; NOT-R2-R6: subu $[[T0:[0-9]+]], $4, $5
79 ; NOT-R2-R6: sll $[[T0]], $[[T0]], 16
80 ; NOT-R2-R6: sra $2, $[[T0]], 16
81
82 ; R2-R6: subu $[[T0:[0-9]+]], $4, $5
83 ; R2-R6: seh $2, $[[T0:[0-9]+]]
84
Zlatko Buljande0bbe62016-04-27 11:31:44 +000085 ; MM: subu16 $[[T0:[0-9]+]], $4, $5
86 ; MM: seh $[[T0]], $[[T0]]
87
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000088 %r = sub i16 %a, %b
89 ret i16 %r
90}
91
92define signext i32 @sub_i32(i32 signext %a, i32 signext %b) {
93entry:
94; ALL-LABEL: sub_i32:
95
Zlatko Buljande0bbe62016-04-27 11:31:44 +000096 ; NOT-MM: subu $2, $4, $5
97
98 ; MM: subu16 $2, $4, $5
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000099
100 %r = sub i32 %a, %b
101 ret i32 %r
102}
103
104define signext i64 @sub_i64(i64 signext %a, i64 signext %b) {
105entry:
106; ALL-LABEL: sub_i64:
107
108 ; GP32: subu $3, $5, $7
109 ; GP32: sltu $[[T0:[0-9]+]], $5, $7
110 ; GP32: addu $[[T1:[0-9]+]], $[[T0]], $6
111 ; GP32: subu $2, $4, $[[T1]]
112
113 ; GP64: dsubu $2, $4, $5
114
115 %r = sub i64 %a, %b
116 ret i64 %r
117}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000118
119define signext i128 @sub_i128(i128 signext %a, i128 signext %b) {
120entry:
121; ALL-LABEL: sub_i128:
122
Zlatko Buljande0bbe62016-04-27 11:31:44 +0000123 ; GP32-NOT-MM: lw $[[T0:[0-9]+]], 20($sp)
124 ; GP32-NOT-MM: sltu $[[T1:[0-9]+]], $5, $[[T0]]
125 ; GP32-NOT-MM: lw $[[T2:[0-9]+]], 16($sp)
126 ; GP32-NOT-MM: addu $[[T3:[0-9]+]], $[[T1]], $[[T2]]
127 ; GP32-NOT-MM: lw $[[T4:[0-9]+]], 24($sp)
128 ; GP32-NOT-MM: lw $[[T5:[0-9]+]], 28($sp)
129 ; GP32-NOT-MM: subu $[[T6:[0-9]+]], $7, $[[T5]]
130 ; GP32-NOT-MM: subu $2, $4, $[[T3]]
131 ; GP32-NOT-MM: sltu $[[T8:[0-9]+]], $6, $[[T4]]
132 ; GP32-NOT-MM: addu $[[T9:[0-9]+]], $[[T8]], $[[T0]]
133 ; GP32-NOT-MM: subu $3, $5, $[[T9]]
134 ; GP32-NOT-MM: sltu $[[T10:[0-9]+]], $7, $[[T5]]
135 ; GP32-NOT-MM: addu $[[T11:[0-9]+]], $[[T10]], $[[T4]]
136 ; GP32-NOT-MM: subu $4, $6, $[[T11]]
137 ; GP32-NOT-MM: move $5, $[[T6]]
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000138
Zlatko Buljande0bbe62016-04-27 11:31:44 +0000139 ; GP32-MM: lw $[[T0:[0-9]+]], 20($sp)
140 ; GP32-MM: sltu $[[T1:[0-9]+]], $[[T2:[0-9]+]], $[[T0]]
141 ; GP32-MM: lw $[[T3:[0-9]+]], 16($sp)
142 ; GP32-MM: addu $[[T3]], $[[T1]], $[[T3]]
143 ; GP32-MM: lw $[[T4:[0-9]+]], 28($sp)
144 ; GP32-MM: subu $[[T1]], $7, $[[T4]]
145 ; GP32-MM: subu $[[T3]], $[[T5:[0-9]+]], $[[T3]]
146 ; GP32-MM: lw $[[T5]], 24($sp)
147 ; GP32-MM: sltu $[[T6:[0-9]+]], $6, $[[T5]]
148 ; GP32-MM: addu $[[T0]], $[[T6]], $[[T0]]
149 ; GP32-MM: subu $[[T0]], $5, $[[T0]]
150 ; GP32-MM: sltu $[[T2]], $7, $[[T4]]
151 ; GP32-MM: addu $[[T5]], $[[T2]], $[[T5]]
152 ; GP32-MM: subu $[[T5]], $6, $[[T5]]
153 ; GP32-MM: move $[[T2]], $[[T1]]
154
155 ; GP64: dsubu $3, $5, $7
156 ; GP64: sltu $[[T0:[0-9]+]], $5, $7
157 ; GP64: daddu $[[T1:[0-9]+]], $[[T0]], $6
158 ; GP64: dsubu $2, $4, $[[T1]]
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000159
160 %r = sub i128 %a, %b
161 ret i128 %r
162}