223 lines · plain
1; RUN: llc -O1 < %s -mtriple=mips64-elf -mcpu=octeon | FileCheck %s -check-prefixes=ALL,OCTEON2; RUN: llc -O1 < %s -mtriple=mips64-elf -mcpu=mips64 | FileCheck %s -check-prefixes=ALL,MIPS643; RUN: llc -O1 < %s -mtriple=mips64-elf -mcpu=octeon -relocation-model=pic | FileCheck %s -check-prefixes=ALL,OCTEON-PIC4 5define i64 @addi64(i64 %a, i64 %b) nounwind {6entry:7; ALL-LABEL: addi64:8; OCTEON: jr $ra9; OCTEON: baddu $2, $4, $510; MIPS64: daddu $[[T0:[0-9]+]], $4, $511; MIPS64: jr $ra12; MIPS64: andi $2, $[[T0]], 25513 %add = add i64 %a, %b14 %and = and i64 %add, 25515 ret i64 %and16}17 18define i64 @mul(i64 %a, i64 %b) nounwind {19entry:20; ALL-LABEL: mul:21; OCTEON: jr $ra22; OCTEON: dmul $2, $4, $523; MIPS64: dmult $4, $524; MIPS64: jr $ra25; MIPS64: mflo $226 %res = mul i64 %a, %b27 ret i64 %res28}29 30define i64 @cmpeq(i64 %a, i64 %b) nounwind {31entry:32; ALL-LABEL: cmpeq:33; OCTEON: jr $ra34; OCTEON: seq $2, $4, $535; MIPS64: xor $[[T0:[0-9]+]], $4, $536; MIPS64: sltiu $[[T1:[0-9]+]], $[[T0]], 137; MIPS64: dsll $[[T2:[0-9]+]], $[[T1]], 3238; MIPS64: jr $ra39; MIPS64: dsrl $2, $[[T2]], 3240 %res = icmp eq i64 %a, %b41 %res2 = zext i1 %res to i6442 ret i64 %res243}44 45define i64 @cmpeqi(i64 %a) nounwind {46entry:47; ALL-LABEL: cmpeqi:48; OCTEON: jr $ra49; OCTEON: seqi $2, $4, 4250; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 4251; MIPS64: xor $[[T1:[0-9]+]], $4, $[[T0]]52; MIPS64: sltiu $[[T2:[0-9]+]], $[[T1]], 153; MIPS64: dsll $[[T3:[0-9]+]], $[[T2]], 3254; MIPS64: jr $ra55; MIPS64: dsrl $2, $[[T3]], 3256 %res = icmp eq i64 %a, 4257 %res2 = zext i1 %res to i6458 ret i64 %res259}60 61define i64 @cmpne(i64 %a, i64 %b) nounwind {62entry:63; ALL-LABEL: cmpne:64; OCTEON: jr $ra65; OCTEON: sne $2, $4, $566; MIPS64: xor $[[T0:[0-9]+]], $4, $567; MIPS64: sltu $[[T1:[0-9]+]], $zero, $[[T0]]68; MIPS64: dsll $[[T2:[0-9]+]], $[[T1]], 3269; MIPS64: jr $ra70; MIPS64: dsrl $2, $[[T2]], 3271 %res = icmp ne i64 %a, %b72 %res2 = zext i1 %res to i6473 ret i64 %res274}75 76define i64 @cmpnei(i64 %a) nounwind {77entry:78; ALL-LABEL: cmpnei:79; OCTEON: jr $ra80; OCTEON: snei $2, $4, 4281; MIPS64: daddiu $[[T0:[0-9]+]], $zero, 4282; MIPS64: xor $[[T1:[0-9]+]], $4, $[[T0]]83; MIPS64: sltu $[[T2:[0-9]+]], $zero, $[[T1]]84; MIPS64: dsll $[[T3:[0-9]+]], $[[T2]], 3285; MIPS64: jr $ra86; MIPS64: dsrl $2, $[[T3]], 3287 %res = icmp ne i64 %a, 4288 %res2 = zext i1 %res to i6489 ret i64 %res290}91 92define i64 @bbit1(i64 %a) nounwind {93entry:94; ALL-LABEL: bbit1: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, 899; MIPS64: bnez $[[T0]], [[BB0:(\$|\.L)BB[0-9_]+]]100 %bit = and i64 %a, 8101 %res = icmp eq i64 %bit, 0102 br i1 %res, label %endif, label %if103if:104 ret i64 48105 106endif:107 ret i64 12108}109 110define i64 @bbit132(i64 %a) nounwind {111entry: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, 1117; MIPS64: dsll $[[T1:[0-9]+]], $[[T0]], 35118; MIPS64: and $[[T2:[0-9]+]], $4, $[[T1]]119; MIPS64: bnez $[[T2]], [[BB0:(\$|\.L)BB[0-9_]+]]120 %bit = and i64 %a, 34359738368121 %res = icmp eq i64 %bit, 0122 br i1 %res, label %endif, label %if123if:124 ret i64 48125 126endif:127 ret i64 12128}129 130define i64 @bbit0(i64 %a) nounwind {131entry:132; ALL-LABEL: bbit0: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, 8137; MIPS64: beqz $[[T0]], [[BB0:(\$|\.L)BB[0-9_]+]]138 %bit = and i64 %a, 8139 %res = icmp ne i64 %bit, 0140 br i1 %res, label %endif, label %if141if:142 ret i64 48143 144endif:145 ret i64 12146}147 148define i64 @bbit032(i64 %a) nounwind {149entry: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, 1155; MIPS64: dsll $[[T1:[0-9]+]], $[[T0]], 35156; MIPS64: and $[[T2:[0-9]+]], $4, $[[T1]]157; MIPS64: beqz $[[T2]], [[BB0:(\$|\.L)BB[0-9_]+]]158 %bit = and i64 %a, 34359738368159 %res = icmp ne i64 %bit, 0160 br i1 %res, label %endif, label %if161if:162 ret i64 48163 164endif:165 ret i64 12166}167 168; extern void foo(void);169; long long var = 7;170; void bbit0i32 () {171; if ((var & 0x2)) {172; foo();173; }174; }175;176; void bbit1i32() {177; if (!(var & 0x2)) {178; foo();179; }180; }181 182@var = local_unnamed_addr global i64 7, align 8183 184define void @bbit0i32() local_unnamed_addr {185entry: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 8191 %and = and i64 %0, 2192 %tobool = icmp eq i64 %and, 0193 br i1 %tobool, label %if.end, label %if.then194 195if.then: ; preds = %entry196 tail call void @foo() #2197 br label %if.end198 199if.end: ; preds = %entry, %if.then200 ret void201}202 203declare void @foo() local_unnamed_addr204 205define void @bbit1i32() local_unnamed_addr {206entry: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 8212 %and = and i64 %0, 2213 %tobool = icmp eq i64 %and, 0214 br i1 %tobool, label %if.then, label %if.end215 216if.then: ; preds = %entry217 tail call void @foo() #2218 br label %if.end219 220if.end: ; preds = %entry, %if.then221 ret void222}223