blob: 617ab3c1a21c7d23ecd1cff2ed230da3b0899e95 [file] [log] [blame]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00001; RUN: llc < %s -march=mips -mcpu=mips2 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00002; RUN: -check-prefixes=NOT-R2-R6,GP32,GP32-NOT-MM,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00003; RUN: llc < %s -march=mips -mcpu=mips32 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00004; RUN: -check-prefixes=NOT-R2-R6,GP32,GP32-NOT-MM,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00005; RUN: llc < %s -march=mips -mcpu=mips32r2 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00006; RUN: -check-prefixes=R2-R6,GP32,GP32-NOT-MM,NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +00007; RUN: llc < %s -march=mips -mcpu=mips32r3 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00008; RUN: -check-prefixes=R2-R6,GP32,GP32-NOT-MM,NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +00009; RUN: llc < %s -march=mips -mcpu=mips32r5 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000010; RUN: -check-prefixes=R2-R6,GP32,GP32-NOT-MM,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000011; RUN: llc < %s -march=mips -mcpu=mips32r6 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000012; RUN: -check-prefixes=R2-R6,GP32,GP32-NOT-MM,NOT-MM
Zlatko Buljande0bbe62016-04-27 11:31:44 +000013; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000014; RUN: -check-prefixes=GP32-MM,GP32,MM
Zlatko Buljande0bbe62016-04-27 11:31:44 +000015; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000016; RUN: -check-prefixes=GP32-MM,GP32,MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000017; RUN: llc < %s -march=mips64 -mcpu=mips3 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000018; RUN: -check-prefixes=NOT-R2-R6,GP64,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000019; RUN: llc < %s -march=mips64 -mcpu=mips4 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000020; RUN: -check-prefixes=NOT-R2-R6,GP64,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000021; RUN: llc < %s -march=mips64 -mcpu=mips64 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000022; RUN: -check-prefixes=NOT-R2-R6,GP64,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000023; RUN: llc < %s -march=mips64 -mcpu=mips64r2 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000024; RUN: -check-prefixes=R2-R6,GP64,NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +000025; RUN: llc < %s -march=mips64 -mcpu=mips64r3 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000026; RUN: -check-prefixes=R2-R6,GP64,NOT-MM
Daniel Sanders17793142015-02-18 16:24:50 +000027; RUN: llc < %s -march=mips64 -mcpu=mips64r5 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000028; RUN: -check-prefixes=R2-R6,GP64,NOT-MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000029; RUN: llc < %s -march=mips64 -mcpu=mips64r6 | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000030; RUN: -check-prefixes=R2-R6,GP64,NOT-MM
Zlatko Buljande0bbe62016-04-27 11:31:44 +000031; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -mattr=+micromips | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000032; RUN: -check-prefixes=GP64,MM
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000033
34define signext i1 @sub_i1(i1 signext %a, i1 signext %b) {
35entry:
36; ALL-LABEL: sub_i1:
37
Zlatko Buljande0bbe62016-04-27 11:31:44 +000038 ; NOT-MM: subu $[[T0:[0-9]+]], $4, $5
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000039 ; NOT-MM: andi $[[T0]], $[[T0]], 1
40 ; NOT-MM: negu $2, $[[T0]]
Zlatko Buljande0bbe62016-04-27 11:31:44 +000041
42 ; MM: subu16 $[[T0:[0-9]+]], $4, $5
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000043 ; MM: andi16 $[[T0]], $[[T0]], 1
44 ; MM: li16 $[[T1:[0-9]+]], 0
45 ; MM: subu16 $2, $[[T1]], $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000046
47 %r = sub i1 %a, %b
48 ret i1 %r
49}
50
51define signext i8 @sub_i8(i8 signext %a, i8 signext %b) {
52entry:
53; ALL-LABEL: sub_i8:
54
55 ; NOT-R2-R6: subu $[[T0:[0-9]+]], $4, $5
56 ; NOT-R2-R6: sll $[[T0]], $[[T0]], 24
57 ; NOT-R2-R6: sra $2, $[[T0]], 24
58
59 ; R2-R6: subu $[[T0:[0-9]+]], $4, $5
60 ; R2-R6: seb $2, $[[T0:[0-9]+]]
61
Zlatko Buljande0bbe62016-04-27 11:31:44 +000062 ; MM: subu16 $[[T0:[0-9]+]], $4, $5
63 ; MM: seb $[[T0]], $[[T0]]
64
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000065 %r = sub i8 %a, %b
66 ret i8 %r
67}
68
69define signext i16 @sub_i16(i16 signext %a, i16 signext %b) {
70entry:
71; ALL-LABEL: sub_i16:
72
73 ; NOT-R2-R6: subu $[[T0:[0-9]+]], $4, $5
74 ; NOT-R2-R6: sll $[[T0]], $[[T0]], 16
75 ; NOT-R2-R6: sra $2, $[[T0]], 16
76
77 ; R2-R6: subu $[[T0:[0-9]+]], $4, $5
78 ; R2-R6: seh $2, $[[T0:[0-9]+]]
79
Zlatko Buljande0bbe62016-04-27 11:31:44 +000080 ; MM: subu16 $[[T0:[0-9]+]], $4, $5
81 ; MM: seh $[[T0]], $[[T0]]
82
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000083 %r = sub i16 %a, %b
84 ret i16 %r
85}
86
87define signext i32 @sub_i32(i32 signext %a, i32 signext %b) {
88entry:
89; ALL-LABEL: sub_i32:
90
Zlatko Buljande0bbe62016-04-27 11:31:44 +000091 ; NOT-MM: subu $2, $4, $5
92
93 ; MM: subu16 $2, $4, $5
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000094
95 %r = sub i32 %a, %b
96 ret i32 %r
97}
98
99define signext i64 @sub_i64(i64 signext %a, i64 signext %b) {
100entry:
101; ALL-LABEL: sub_i64:
102
103 ; GP32: subu $3, $5, $7
104 ; GP32: sltu $[[T0:[0-9]+]], $5, $7
105 ; GP32: addu $[[T1:[0-9]+]], $[[T0]], $6
106 ; GP32: subu $2, $4, $[[T1]]
107
108 ; GP64: dsubu $2, $4, $5
109
110 %r = sub i64 %a, %b
111 ret i64 %r
112}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000113
114define signext i128 @sub_i128(i128 signext %a, i128 signext %b) {
115entry:
116; ALL-LABEL: sub_i128:
117
Zlatko Buljande0bbe62016-04-27 11:31:44 +0000118 ; GP32-NOT-MM: lw $[[T0:[0-9]+]], 20($sp)
119 ; GP32-NOT-MM: sltu $[[T1:[0-9]+]], $5, $[[T0]]
120 ; GP32-NOT-MM: lw $[[T2:[0-9]+]], 16($sp)
121 ; GP32-NOT-MM: addu $[[T3:[0-9]+]], $[[T1]], $[[T2]]
122 ; GP32-NOT-MM: lw $[[T4:[0-9]+]], 24($sp)
123 ; GP32-NOT-MM: lw $[[T5:[0-9]+]], 28($sp)
124 ; GP32-NOT-MM: subu $[[T6:[0-9]+]], $7, $[[T5]]
125 ; GP32-NOT-MM: subu $2, $4, $[[T3]]
126 ; GP32-NOT-MM: sltu $[[T8:[0-9]+]], $6, $[[T4]]
127 ; GP32-NOT-MM: addu $[[T9:[0-9]+]], $[[T8]], $[[T0]]
128 ; GP32-NOT-MM: subu $3, $5, $[[T9]]
129 ; GP32-NOT-MM: sltu $[[T10:[0-9]+]], $7, $[[T5]]
130 ; GP32-NOT-MM: addu $[[T11:[0-9]+]], $[[T10]], $[[T4]]
131 ; GP32-NOT-MM: subu $4, $6, $[[T11]]
132 ; GP32-NOT-MM: move $5, $[[T6]]
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000133
Zlatko Buljande0bbe62016-04-27 11:31:44 +0000134 ; GP32-MM: lw $[[T0:[0-9]+]], 20($sp)
135 ; GP32-MM: sltu $[[T1:[0-9]+]], $[[T2:[0-9]+]], $[[T0]]
136 ; GP32-MM: lw $[[T3:[0-9]+]], 16($sp)
137 ; GP32-MM: addu $[[T3]], $[[T1]], $[[T3]]
Simon Dardisbd271542016-09-01 14:53:53 +0000138 ; GP32-MM: lw $[[T4:[0-9]+]], 24($sp)
139 ; GP32-MM: lw $[[T5:[0-9]+]], 28($sp)
140 ; GP32-MM: subu $[[T1]], $7, $[[T5]]
141 ; GP32-MM: subu $[[T3]], $[[T6:[0-9]+]], $[[T3]]
142 ; GP32-MM: sltu $[[T6]], $6, $[[T4]]
Zlatko Buljande0bbe62016-04-27 11:31:44 +0000143 ; GP32-MM: addu $[[T0]], $[[T6]], $[[T0]]
144 ; GP32-MM: subu $[[T0]], $5, $[[T0]]
Simon Dardisbd271542016-09-01 14:53:53 +0000145 ; GP32-MM: sltu $[[T6]], $7, $[[T5]]
146 ; GP32-MM: addu $[[T6]], $[[T6]], $[[T4]]
147 ; GP32-MM: subu $[[T6]], $6, $[[T6]]
Zlatko Buljande0bbe62016-04-27 11:31:44 +0000148 ; GP32-MM: move $[[T2]], $[[T1]]
149
150 ; GP64: dsubu $3, $5, $7
151 ; GP64: sltu $[[T0:[0-9]+]], $5, $7
152 ; GP64: daddu $[[T1:[0-9]+]], $[[T0]], $6
153 ; GP64: dsubu $2, $4, $[[T1]]
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000154
155 %r = sub i128 %a, %b
156 ret i128 %r
157}