1 ; RUN: llc -O1 < %s -march=mips64 -mcpu=octeon | FileCheck %s -check-prefixes=ALL,OCTEON
2 ; RUN: llc -O1 < %s -march=mips64 -mcpu=mips64 | FileCheck %s -check-prefixes=ALL,MIPS64
3 ; RUN: llc -O1 < %s -march=mips64 -mcpu=octeon -relocation-model=pic | FileCheck %s -check-prefixes=ALL,OCTEON-PIC
5 define i64 @addi64(i64 %a, i64 %b) nounwind {
9 ; OCTEON: baddu $2, $4, $5
10 ; MIPS64: daddu $[[T0:[0-9]+]], $4, $5
12 ; MIPS64: andi $2, $[[T0]], 255
14 %and = and i64 %add, 255
18 define i64 @mul(i64 %a, i64 %b) nounwind {
22 ; OCTEON: dmul $2, $4, $5
23 ; MIPS64: dmult $4, $5
30 define i64 @cmpeq(i64 %a, i64 %b) nounwind {
34 ; OCTEON: seq $2, $4, $5
35 ; MIPS64: xor $[[T0:[0-9]+]], $4, $5
36 ; MIPS64: sltiu $[[T1:[0-9]+]], $[[T0]], 1
37 ; MIPS64: dsll $[[T2:[0-9]+]], $[[T1]], 32
39 ; MIPS64: dsrl $2, $[[T2]], 32
40 %res = icmp eq i64 %a, %b
41 %res2 = zext i1 %res to i64
45 define i64 @cmpeqi(i64 %a) nounwind {
49 ; OCTEON: seqi $2, $4, 42
50 ; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 42
51 ; MIPS64: xor $[[T1:[0-9]+]], $4, $[[T0]]
52 ; MIPS64: sltiu $[[T2:[0-9]+]], $[[T1]], 1
53 ; MIPS64: dsll $[[T3:[0-9]+]], $[[T2]], 32
55 ; MIPS64: dsrl $2, $[[T3]], 32
56 %res = icmp eq i64 %a, 42
57 %res2 = zext i1 %res to i64
61 define i64 @cmpne(i64 %a, i64 %b) nounwind {
65 ; OCTEON: sne $2, $4, $5
66 ; MIPS64: xor $[[T0:[0-9]+]], $4, $5
67 ; MIPS64: sltu $[[T1:[0-9]+]], $zero, $[[T0]]
68 ; MIPS64: dsll $[[T2:[0-9]+]], $[[T1]], 32
70 ; MIPS64: dsrl $2, $[[T2]], 32
71 %res = icmp ne i64 %a, %b
72 %res2 = zext i1 %res to i64
76 define i64 @cmpnei(i64 %a) nounwind {
80 ; OCTEON: snei $2, $4, 42
81 ; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 42
82 ; MIPS64: xor $[[T1:[0-9]+]], $4, $[[T0]]
83 ; MIPS64: sltu $[[T2:[0-9]+]], $zero, $[[T1]]
84 ; MIPS64: dsll $[[T3:[0-9]+]], $[[T2]], 32
86 ; MIPS64: dsrl $2, $[[T3]], 32
87 %res = icmp ne i64 %a, 42
88 %res2 = zext i1 %res to i64
92 define i64 @bbit1(i64 %a) nounwind {
95 ; OCTEON: bbit1 $4, 3, [[BB0:(\$|\.L)BB[0-9_]+]]
96 ; OCTEON-PIC-NOT: b {{[[:space:]].*}}
97 ; OCTEON-NOT: j {{[[:space:]].*}}
98 ; MIPS64: andi $[[T0:[0-9]+]], $4, 8
99 ; MIPS64: bnez $[[T0]], [[BB0:(\$|\.L)BB[0-9_]+]]
101 %res = icmp eq i64 %bit, 0
102 br i1 %res, label %endif, label %if
110 define i64 @bbit132(i64 %a) nounwind {
112 ; ALL-LABEL: bbit132:
113 ; OCTEON: bbit132 $4, 3, [[BB0:(\$|\.L)BB[0-9_]+]]
114 ; OCTEON-PIC-NOT: b {{[[:space:]].*}}
115 ; OCTEON-NOT: j {{[[:space:]].*}}
116 ; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 1
117 ; MIPS64: dsll $[[T1:[0-9]+]], $[[T0]], 35
118 ; MIPS64: and $[[T2:[0-9]+]], $4, $[[T1]]
119 ; MIPS64: bnez $[[T2]], [[BB0:(\$|\.L)BB[0-9_]+]]
120 %bit = and i64 %a, 34359738368
121 %res = icmp eq i64 %bit, 0
122 br i1 %res, label %endif, label %if
130 define i64 @bbit0(i64 %a) nounwind {
133 ; OCTEON: bbit0 $4, 3, [[BB0:(\$|\.L)BB[0-9_]+]]
134 ; OCTEON-PIC-NOT: b {{[[:space:]].*}}
135 ; OCTEON-NOT: j {{[[:space:]].*}}
136 ; MIPS64: andi $[[T0:[0-9]+]], $4, 8
137 ; MIPS64: beqz $[[T0]], [[BB0:(\$|\.L)BB[0-9_]+]]
139 %res = icmp ne i64 %bit, 0
140 br i1 %res, label %endif, label %if
148 define i64 @bbit032(i64 %a) nounwind {
150 ; ALL-LABEL: bbit032:
151 ; OCTEON: bbit032 $4, 3, [[BB0:(\$|\.L)BB[0-9_]+]]
152 ; OCTEON-PIC-NOT: b {{[[:space:]].*}}
153 ; OCTEON-NOT: j {{[[:space:]].*}}
154 ; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 1
155 ; MIPS64: dsll $[[T1:[0-9]+]], $[[T0]], 35
156 ; MIPS64: and $[[T2:[0-9]+]], $4, $[[T1]]
157 ; MIPS64: beqz $[[T2]], [[BB0:(\$|\.L)BB[0-9_]+]]
158 %bit = and i64 %a, 34359738368
159 %res = icmp ne i64 %bit, 0
160 br i1 %res, label %endif, label %if
168 ; extern void foo(void);
177 ; if (!(var & 0x2)) {
182 @var = local_unnamed_addr global i64 7, align 8
184 define void @bbit0i32() local_unnamed_addr {
186 ; ALL-LABEL: bbit0i32:
187 ; OCTEON: bbit0 $1, 1, [[BB0:(\$|\.L)BB[0-9_]+]]
188 ; OCTEON-PIC-NOT: b {{[[:space:]].*}}
189 ; OCTEON-NOT: j {{[[:space:]].*}}
190 %0 = load i64, ptr @var, align 8
192 %tobool = icmp eq i64 %and, 0
193 br i1 %tobool, label %if.end, label %if.then
195 if.then: ; preds = %entry
196 tail call void @foo() #2
199 if.end: ; preds = %entry, %if.then
203 declare void @foo() local_unnamed_addr
205 define void @bbit1i32() local_unnamed_addr {
207 ; ALL-LABEL: bbit1i32:
208 ; OCTEON: bbit1 $1, 1, [[BB0:(\$|\.L)BB[0-9_]+]]
209 ; OCTEON-PIC-NOT: b {{[[:space:]].*}}
210 ; OCTEON-NOT: j {{[[:space:]].*}}
211 %0 = load i64, ptr @var, align 8
213 %tobool = icmp eq i64 %and, 0
214 br i1 %tobool, label %if.then, label %if.end
216 if.then: ; preds = %entry
217 tail call void @foo() #2
220 if.end: ; preds = %entry, %if.then