[mips] Add octeon branch instructions bbit0/bbit032/bbit1/bbit132
[oota-llvm.git] / test / CodeGen / Mips / octeon.ll
1 ; RUN: llc -O1 < %s -march=mips64 -mcpu=octeon | FileCheck %s -check-prefix=OCTEON
2 ; RUN: llc -O1 < %s -march=mips64 -mcpu=mips64 | FileCheck %s -check-prefix=MIPS64
3
4 define i64 @addi64(i64 %a, i64 %b) nounwind {
5 entry:
6 ; OCTEON-LABEL: addi64:
7 ; OCTEON: jr      $ra
8 ; OCTEON: baddu   $2, $4, $5
9 ; MIPS64-LABEL: addi64:
10 ; MIPS64: daddu
11 ; MIPS64: jr
12 ; MIPS64: andi
13   %add = add i64 %a, %b
14   %and = and i64 %add, 255
15   ret i64 %and
16 }
17
18 define i64 @mul(i64 %a, i64 %b) nounwind {
19 entry:
20 ; OCTEON-LABEL: mul:
21 ; OCTEON: jr    $ra
22 ; OCTEON: dmul  $2, $4, $5
23 ; MIPS64-LABEL: mul:
24 ; MIPS64: dmult
25 ; MIPS64: jr
26 ; MIPS64: mflo
27   %res = mul i64 %a, %b
28   ret i64 %res
29 }
30
31 define i64 @cmpeq(i64 %a, i64 %b) nounwind {
32 entry:
33 ; OCTEON-LABEL: cmpeq:
34 ; OCTEON: jr     $ra
35 ; OCTEON: seq    $2, $4, $5
36 ; MIPS64-LABEL: cmpeq:
37 ; MIPS64: xor    $1, $4, $5
38 ; MIPS64: sltiu  $1, $1, 1
39 ; MIPS64: dsll   $1, $1, 32
40 ; MIPS64: jr     $ra
41 ; MIPS64: dsrl   $2, $1, 32
42   %res = icmp eq i64 %a, %b
43   %res2 = zext i1 %res to i64
44   ret i64 %res2
45 }
46
47 define i64 @cmpeqi(i64 %a) nounwind {
48 entry:
49 ; OCTEON-LABEL: cmpeqi:
50 ; OCTEON: jr     $ra
51 ; OCTEON: seqi   $2, $4, 42
52 ; MIPS64-LABEL: cmpeqi:
53 ; MIPS64: daddiu $1, $zero, 42
54 ; MIPS64: xor    $1, $4, $1
55 ; MIPS64: sltiu  $1, $1, 1
56 ; MIPS64: dsll   $1, $1, 32
57 ; MIPS64: jr     $ra
58 ; MIPS64: dsrl   $2, $1, 32
59   %res = icmp eq i64 %a, 42
60   %res2 = zext i1 %res to i64
61   ret i64 %res2
62 }
63
64 define i64 @cmpne(i64 %a, i64 %b) nounwind {
65 entry:
66 ; OCTEON-LABEL: cmpne:
67 ; OCTEON: jr     $ra
68 ; OCTEON: sne    $2, $4, $5
69 ; MIPS64-LABEL: cmpne:
70 ; MIPS64: xor    $1, $4, $5
71 ; MIPS64: sltu   $1, $zero, $1
72 ; MIPS64: dsll   $1, $1, 32
73 ; MIPS64: jr     $ra
74 ; MIPS64: dsrl   $2, $1, 32
75   %res = icmp ne i64 %a, %b
76   %res2 = zext i1 %res to i64
77   ret i64 %res2
78 }
79
80 define i64 @cmpnei(i64 %a) nounwind {
81 entry:
82 ; OCTEON-LABEL: cmpnei:
83 ; OCTEON: jr     $ra
84 ; OCTEON: snei   $2, $4, 42
85 ; MIPS64-LABEL: cmpnei:
86 ; MIPS64: daddiu $1, $zero, 42
87 ; MIPS64: xor    $1, $4, $1
88 ; MIPS64: sltu   $1, $zero, $1
89 ; MIPS64: dsll   $1, $1, 32
90 ; MIPS64: jr     $ra
91 ; MIPS64: dsrl   $2, $1, 32
92   %res = icmp ne i64 %a, 42
93   %res2 = zext i1 %res to i64
94   ret i64 %res2
95 }
96
97 define i64 @bbit0(i64 %a) nounwind {
98 entry:
99 ; OCTEON-LABEL: bbit0:
100 ; OCTEON: bbit0   $4, 3, $[[BB0:BB[0-9_]+]]
101 ; MIPS64-LABEL: bbit0:
102 ; MIPS64: andi  $[[T0:[0-9]+]], $4, 8
103 ; MIPS64: beqz  $[[T0]], $[[BB0:BB[0-9_]+]]
104   %bit = and i64 %a, 8
105   %res = icmp eq i64 %bit, 0
106   br i1 %res, label %endif, label %if
107 if:
108   ret i64 48
109
110 endif:
111   ret i64 12
112 }
113
114 define i64 @bbit032(i64 %a) nounwind {
115 entry:
116 ; OCTEON-LABEL: bbit032:
117 ; OCTEON: bbit032 $4, 3, $[[BB0:BB[0-9_]+]]
118 ; MIPS64-LABEL: bbit032:
119 ; MIPS64: daddiu  $[[T0:[0-9]+]], $zero, 1
120 ; MIPS64: dsll    $[[T1:[0-9]+]], $[[T0]], 35
121 ; MIPS64: and     $[[T2:[0-9]+]], $4, $[[T1]]
122 ; MIPS64: beqz    $[[T2]], $[[BB0:BB[0-9_]+]]
123   %bit = and i64 %a, 34359738368
124   %res = icmp eq i64 %bit, 0
125   br i1 %res, label %endif, label %if
126 if:
127   ret i64 48
128
129 endif:
130   ret i64 12
131 }
132
133 define i64 @bbit1(i64 %a) nounwind {
134 entry:
135 ; OCTEON-LABEL: bbit1:
136 ; OCTEON: bbit1 $4, 3, $[[BB0:BB[0-9_]+]]
137 ; MIPS64-LABEL: bbit1:
138 ; MIPS64: andi  $[[T0:[0-9]+]], $4, 8
139 ; MIPS64: beqz  $[[T0]], $[[BB0:BB[0-9_]+]]
140   %bit = and i64 %a, 8
141   %res = icmp ne i64 %bit, 0
142   br i1 %res, label %endif, label %if
143 if:
144   ret i64 48
145
146 endif:
147   ret i64 12
148 }
149
150 define i64 @bbit132(i64 %a) nounwind {
151 entry:
152 ; OCTEON-LABEL: bbit132:
153 ; OCTEON: bbit132 $4, 3, $[[BB0:BB[0-9_]+]]
154 ; MIPS64-LABEL: bbit132:
155 ; MIPS64: daddiu  $[[T0:[0-9]+]], $zero, 1
156 ; MIPS64: dsll    $[[T1:[0-9]+]], $[[T0]], 35
157 ; MIPS64: and     $[[T2:[0-9]+]], $4, $[[T1]]
158 ; MIPS64: beqz    $[[T2]], $[[BB0:BB[0-9_]+]]
159   %bit = and i64 %a, 34359738368
160   %res = icmp ne i64 %bit, 0
161   br i1 %res, label %endif, label %if
162 if:
163   ret i64 48
164
165 endif:
166   ret i64 12
167 }