• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=mips -mcpu=mips32r6 -O1 -start-after=dwarfehprepare < %s | FileCheck %s
2; RUN: llc -march=mips64 -mcpu=mips64r6 -O1 -start-after=dwarfehprepare < %s | FileCheck %s
3
4
5; beqc/bnec have the constraint that $rs < $rt && $rs != 0 && $rt != 0
6; Cases where $rs == 0 and $rt != 0 should be transformed into beqzc/bnezc.
7; Cases where $rs > $rt can have the operands swapped as ==,!= are commutative.
8
9; Cases where beq & bne where $rs == $rt have to inhibited from being turned
10; into compact branches but arguably should not occur. This test covers the
11; $rs == $rt case.
12
13; Starting from dwarf exception handling preparation skips optimizations that
14; may simplify out the crucical bnec $4, $4 instruction.
15
16define internal void @_ZL14TestRemoveLastv(i32* %alist.sroa.0.4) {
17; CHECK-LABEL: _ZL14TestRemoveLastv:
18entry:
19  %ascevgep = getelementptr i32, i32* %alist.sroa.0.4, i64 99
20  br label %do.body121
21
22for.cond117:
23  %alsr.iv.next = add nsw i32 %alsr.iv, -1
24  %ascevgep340 = getelementptr i32, i32* %alsr.iv339, i64 -1
25  %acmp118 = icmp sgt i32 %alsr.iv.next, 0
26  br i1 %acmp118, label %do.body121, label %if.then143
27
28do.body121:
29  %alsr.iv339 = phi i32* [ %ascevgep, %entry ], [ %ascevgep340, %for.cond117 ]
30  %alsr.iv = phi i32 [ 100, %entry ], [ %alsr.iv.next, %for.cond117 ]
31  %a9 = add i32 %alsr.iv, -1
32  %alnot124 = icmp eq i32 %alsr.iv, %alsr.iv
33  br i1 %alnot124, label %do.body134, label %if.then143, !prof !11
34
35do.body134:
36  %a10 = add i32 %alsr.iv, -1
37  %a11 = load i32, i32* %alsr.iv339, align 4, !tbaa !5
38; CHECK-NOT: bnec $[[R0:[0-9]+]], $[[R0]]
39; CHECK-NOT: beqc $[[R1:[0-9]+]], $[[R1]]
40  %alnot137 = icmp eq i32 %a9, %a11
41  br i1 %alnot137, label %do.end146, label %if.then143, !prof !11
42
43if.then143:
44 ret void
45 unreachable
46
47do.end146:
48  %alnot151 = icmp eq i32 %a9, %a10
49  br i1 %alnot151, label %for.cond117, label %if.then143, !prof !11
50
51}
52
53define internal void @_ZL14TestRemoveLastv64(i64* %alist.sroa.0.4) {
54; CHECK-LABEL: _ZL14TestRemoveLastv64:
55entry:
56  %ascevgep = getelementptr i64, i64* %alist.sroa.0.4, i64 99
57  br label %do.body121
58
59for.cond117:
60  %alsr.iv.next = add nsw i64 %alsr.iv, -1
61  %ascevgep340 = getelementptr i64, i64* %alsr.iv339, i64 -1
62  %acmp118 = icmp sgt i64 %alsr.iv.next, 0
63  br i1 %acmp118, label %do.body121, label %if.then143
64
65do.body121:
66  %alsr.iv339 = phi i64* [ %ascevgep, %entry ], [ %ascevgep340, %for.cond117 ]
67  %alsr.iv = phi i64 [ 100, %entry ], [ %alsr.iv.next, %for.cond117 ]
68  %a9 = add i64 %alsr.iv, -1
69  %alnot124 = icmp eq i64 %alsr.iv, %alsr.iv
70  br i1 %alnot124, label %do.body134, label %if.then143, !prof !11
71
72do.body134:
73  %a10 = add i64 %alsr.iv, -1
74  %a11 = load i64, i64* %alsr.iv339, align 4, !tbaa !5
75; CHECK-NOT: bnec $[[R0:[0-9]+]], $[[R0]]
76; CHECK-NOT: beqc $[[R1:[0-9]+]], $[[R1]]
77  %alnot137 = icmp eq i64 %a9, %a11
78  br i1 %alnot137, label %do.end146, label %if.then143, !prof !11
79
80if.then143:
81 ret void
82 unreachable
83
84do.end146:
85  %alnot151 = icmp eq i64 %a9, %a10
86  br i1 %alnot151, label %for.cond117, label %if.then143, !prof !11
87
88}
89!3 = !{!"omnipotent char", !4, i64 0}
90!4 = !{!"Simple C++ TBAA"}
91!5 = !{!6, !6, i64 0}
92!6 = !{!"int", !3, i64 0}
93!11 = !{!"branch_weights", i32 2000, i32 1}
94!12 = !{!"branch_weights", i32 -388717296, i32 7818360}
95
96