blob: 499ce3c1ddbf048fa121b128075fa98804ad269c [file] [log] [blame]
Kai Nackee7a64782015-01-20 16:14:02 +00001; RUN: llc -O1 < %s -march=mips64 -mcpu=octeon | FileCheck %s -check-prefix=ALL -check-prefix=OCTEON
2; RUN: llc -O1 < %s -march=mips64 -mcpu=mips64 | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64
Kai Nacke93fe5e82014-03-20 11:51:58 +00003
Kai Nacke13673ac2014-04-02 18:40:43 +00004define i64 @addi64(i64 %a, i64 %b) nounwind {
5entry:
Kai Nackee7a64782015-01-20 16:14:02 +00006; ALL-LABEL: addi64:
Kai Nacke13673ac2014-04-02 18:40:43 +00007; OCTEON: jr $ra
8; OCTEON: baddu $2, $4, $5
Kai Nackee7a64782015-01-20 16:14:02 +00009; MIPS64: daddu $[[T0:[0-9]+]], $4, $5
10; MIPS64: jr $ra
11; MIPS64: andi $2, $[[T0]], 255
Kai Nacke13673ac2014-04-02 18:40:43 +000012 %add = add i64 %a, %b
13 %and = and i64 %add, 255
14 ret i64 %and
15}
16
Kai Nacke93fe5e82014-03-20 11:51:58 +000017define i64 @mul(i64 %a, i64 %b) nounwind {
18entry:
Kai Nackee7a64782015-01-20 16:14:02 +000019; ALL-LABEL: mul:
Kai Nacke93fe5e82014-03-20 11:51:58 +000020; OCTEON: jr $ra
21; OCTEON: dmul $2, $4, $5
Kai Nackee7a64782015-01-20 16:14:02 +000022; MIPS64: dmult $4, $5
23; MIPS64: jr $ra
24; MIPS64: mflo $2
Kai Nacke93fe5e82014-03-20 11:51:58 +000025 %res = mul i64 %a, %b
26 ret i64 %res
27}
Kai Nacke755b6e82015-01-14 10:19:09 +000028
29define i64 @cmpeq(i64 %a, i64 %b) nounwind {
30entry:
Kai Nackee7a64782015-01-20 16:14:02 +000031; ALL-LABEL: cmpeq:
Kai Nacke755b6e82015-01-14 10:19:09 +000032; OCTEON: jr $ra
33; OCTEON: seq $2, $4, $5
Kai Nackee7a64782015-01-20 16:14:02 +000034; MIPS64: xor $[[T0:[0-9]+]], $4, $5
35; MIPS64: sltiu $[[T1:[0-9]+]], $[[T0]], 1
36; MIPS64: dsll $[[T2:[0-9]+]], $[[T1]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000037; MIPS64: jr $ra
Kai Nackee7a64782015-01-20 16:14:02 +000038; MIPS64: dsrl $2, $[[T2]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000039 %res = icmp eq i64 %a, %b
40 %res2 = zext i1 %res to i64
41 ret i64 %res2
42}
43
44define i64 @cmpeqi(i64 %a) nounwind {
45entry:
Kai Nackee7a64782015-01-20 16:14:02 +000046; ALL-LABEL: cmpeqi:
Kai Nacke755b6e82015-01-14 10:19:09 +000047; OCTEON: jr $ra
48; OCTEON: seqi $2, $4, 42
Kai Nackee7a64782015-01-20 16:14:02 +000049; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 42
50; MIPS64: xor $[[T1:[0-9]+]], $4, $[[T0]]
51; MIPS64: sltiu $[[T2:[0-9]+]], $[[T1]], 1
52; MIPS64: dsll $[[T3:[0-9]+]], $[[T2]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000053; MIPS64: jr $ra
Kai Nackee7a64782015-01-20 16:14:02 +000054; MIPS64: dsrl $2, $[[T3]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000055 %res = icmp eq i64 %a, 42
56 %res2 = zext i1 %res to i64
57 ret i64 %res2
58}
59
60define i64 @cmpne(i64 %a, i64 %b) nounwind {
61entry:
Kai Nackee7a64782015-01-20 16:14:02 +000062; ALL-LABEL: cmpne:
Kai Nacke755b6e82015-01-14 10:19:09 +000063; OCTEON: jr $ra
64; OCTEON: sne $2, $4, $5
Kai Nackee7a64782015-01-20 16:14:02 +000065; MIPS64: xor $[[T0:[0-9]+]], $4, $5
66; MIPS64: sltu $[[T1:[0-9]+]], $zero, $[[T0]]
67; MIPS64: dsll $[[T2:[0-9]+]], $[[T1]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000068; MIPS64: jr $ra
Kai Nackee7a64782015-01-20 16:14:02 +000069; MIPS64: dsrl $2, $[[T2]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000070 %res = icmp ne i64 %a, %b
71 %res2 = zext i1 %res to i64
72 ret i64 %res2
73}
74
75define i64 @cmpnei(i64 %a) nounwind {
76entry:
Kai Nackee7a64782015-01-20 16:14:02 +000077; ALL-LABEL: cmpnei:
Kai Nacke755b6e82015-01-14 10:19:09 +000078; OCTEON: jr $ra
79; OCTEON: snei $2, $4, 42
Kai Nackee7a64782015-01-20 16:14:02 +000080; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 42
81; MIPS64: xor $[[T1:[0-9]+]], $4, $[[T0]]
82; MIPS64: sltu $[[T2:[0-9]+]], $zero, $[[T1]]
83; MIPS64: dsll $[[T3:[0-9]+]], $[[T2]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000084; MIPS64: jr $ra
Kai Nackee7a64782015-01-20 16:14:02 +000085; MIPS64: dsrl $2, $[[T3]], 32
Kai Nacke755b6e82015-01-14 10:19:09 +000086 %res = icmp ne i64 %a, 42
87 %res2 = zext i1 %res to i64
88 ret i64 %res2
89}
Kai Nacke63072f82015-01-20 16:10:51 +000090
91define i64 @bbit0(i64 %a) nounwind {
92entry:
Kai Nackee7a64782015-01-20 16:14:02 +000093; ALL-LABEL: bbit0:
Daniel Sanders69c60082015-05-20 14:18:59 +000094; OCTEON: bbit0 $4, 3, $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +000095; MIPS64: andi $[[T0:[0-9]+]], $4, 8
Daniel Sanders69c60082015-05-20 14:18:59 +000096; MIPS64: bnez $[[T0]], $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +000097 %bit = and i64 %a, 8
98 %res = icmp eq i64 %bit, 0
99 br i1 %res, label %endif, label %if
100if:
101 ret i64 48
102
103endif:
104 ret i64 12
105}
106
107define i64 @bbit032(i64 %a) nounwind {
108entry:
Kai Nackee7a64782015-01-20 16:14:02 +0000109; ALL-LABEL: bbit032:
Daniel Sanders69c60082015-05-20 14:18:59 +0000110; OCTEON: bbit032 $4, 3, $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +0000111; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 1
112; MIPS64: dsll $[[T1:[0-9]+]], $[[T0]], 35
113; MIPS64: and $[[T2:[0-9]+]], $4, $[[T1]]
Daniel Sanders69c60082015-05-20 14:18:59 +0000114; MIPS64: bnez $[[T2]], $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +0000115 %bit = and i64 %a, 34359738368
116 %res = icmp eq i64 %bit, 0
117 br i1 %res, label %endif, label %if
118if:
119 ret i64 48
120
121endif:
122 ret i64 12
123}
124
125define i64 @bbit1(i64 %a) nounwind {
126entry:
Kai Nackee7a64782015-01-20 16:14:02 +0000127; ALL-LABEL: bbit1:
Daniel Sanders69c60082015-05-20 14:18:59 +0000128; OCTEON: bbit1 $4, 3, $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +0000129; MIPS64: andi $[[T0:[0-9]+]], $4, 8
Daniel Sanders69c60082015-05-20 14:18:59 +0000130; MIPS64: beqz $[[T0]], $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +0000131 %bit = and i64 %a, 8
132 %res = icmp ne i64 %bit, 0
133 br i1 %res, label %endif, label %if
134if:
135 ret i64 48
136
137endif:
138 ret i64 12
139}
140
141define i64 @bbit132(i64 %a) nounwind {
142entry:
Kai Nackee7a64782015-01-20 16:14:02 +0000143; ALL-LABEL: bbit132:
Daniel Sanders69c60082015-05-20 14:18:59 +0000144; OCTEON: bbit132 $4, 3, $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +0000145; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 1
146; MIPS64: dsll $[[T1:[0-9]+]], $[[T0]], 35
147; MIPS64: and $[[T2:[0-9]+]], $4, $[[T1]]
Daniel Sanders69c60082015-05-20 14:18:59 +0000148; MIPS64: beqz $[[T2]], $[[BB0:BB[0-9_]+]]
Kai Nacke63072f82015-01-20 16:10:51 +0000149 %bit = and i64 %a, 34359738368
150 %res = icmp ne i64 %bit, 0
151 br i1 %res, label %endif, label %if
152if:
153 ret i64 48
154
155endif:
156 ret i64 12
157}