xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/compactbranches/beqc-bnec-register-constraint.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips -mcpu=mips32r6 -O1 -start-after=dwarfehprepare < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; beqc/bnec have the constraint that $rs < $rt && $rs != 0 && $rt != 0
4*9880d681SAndroid Build Coastguard Worker; Cases where $rs == 0 and $rt != 0 should be transformed into beqzc/bnezc.
5*9880d681SAndroid Build Coastguard Worker; Cases where $rs > $rt can have the operands swapped as ==,!= are commutative.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; Cases where beq & bne where $rs == $rt have to inhibited from being turned
8*9880d681SAndroid Build Coastguard Worker; into compact branches but arguably should not occur. This test covers the
9*9880d681SAndroid Build Coastguard Worker; $rs == $rt case.
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker; Starting from dwarf exception handling preparation skips optimizations that
12*9880d681SAndroid Build Coastguard Worker; may simplify out the crucical bnec $4, $4 instruction.
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine internal void @_ZL14TestRemoveLastv(i32* %alist.sroa.0.4) {
15*9880d681SAndroid Build Coastguard Workerentry:
16*9880d681SAndroid Build Coastguard Worker  %ascevgep = getelementptr i32, i32* %alist.sroa.0.4, i64 99
17*9880d681SAndroid Build Coastguard Worker  br label %do.body121
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerfor.cond117:
20*9880d681SAndroid Build Coastguard Worker  %alsr.iv.next = add nsw i32 %alsr.iv, -1
21*9880d681SAndroid Build Coastguard Worker  %ascevgep340 = getelementptr i32, i32* %alsr.iv339, i64 -1
22*9880d681SAndroid Build Coastguard Worker  %acmp118 = icmp sgt i32 %alsr.iv.next, 0
23*9880d681SAndroid Build Coastguard Worker  br i1 %acmp118, label %do.body121, label %if.then143
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Workerdo.body121:
26*9880d681SAndroid Build Coastguard Worker  %alsr.iv339 = phi i32* [ %ascevgep, %entry ], [ %ascevgep340, %for.cond117 ]
27*9880d681SAndroid Build Coastguard Worker  %alsr.iv = phi i32 [ 100, %entry ], [ %alsr.iv.next, %for.cond117 ]
28*9880d681SAndroid Build Coastguard Worker  %a9 = add i32 %alsr.iv, -1
29*9880d681SAndroid Build Coastguard Worker  %alnot124 = icmp eq i32 %alsr.iv, %alsr.iv
30*9880d681SAndroid Build Coastguard Worker  br i1 %alnot124, label %do.body134, label %if.then143, !prof !11
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerdo.body134:
33*9880d681SAndroid Build Coastguard Worker  %a10 = add i32 %alsr.iv, -1
34*9880d681SAndroid Build Coastguard Worker  %a11 = load i32, i32* %alsr.iv339, align 4, !tbaa !5
35*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: bnec $[[R0:[0-9]+]], $[[R0]]
36*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: beqc $[[R1:[0-9]+]], $[[R1]]
37*9880d681SAndroid Build Coastguard Worker  %alnot137 = icmp eq i32 %a9, %a11
38*9880d681SAndroid Build Coastguard Worker  br i1 %alnot137, label %do.end146, label %if.then143, !prof !11
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerif.then143:
41*9880d681SAndroid Build Coastguard Worker ret void
42*9880d681SAndroid Build Coastguard Worker unreachable
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerdo.end146:
45*9880d681SAndroid Build Coastguard Worker  %alnot151 = icmp eq i32 %a9, %a10
46*9880d681SAndroid Build Coastguard Worker  br i1 %alnot151, label %for.cond117, label %if.then143, !prof !11
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker}
49*9880d681SAndroid Build Coastguard Worker!3 = !{!"omnipotent char", !4, i64 0}
50*9880d681SAndroid Build Coastguard Worker!4 = !{!"Simple C++ TBAA"}
51*9880d681SAndroid Build Coastguard Worker!5 = !{!6, !6, i64 0}
52*9880d681SAndroid Build Coastguard Worker!6 = !{!"int", !3, i64 0}
53*9880d681SAndroid Build Coastguard Worker!11 = !{!"branch_weights", i32 2000, i32 1}
54*9880d681SAndroid Build Coastguard Worker!12 = !{!"branch_weights", i32 -388717296, i32 7818360}
55*9880d681SAndroid Build Coastguard Worker
56