1 ; RUN: llc -mtriple=mipsel -O0 < %s | FileCheck %s -check-prefix=None
2 ; RUN: llc -mtriple=mipsel -relocation-model=pic < %s | \
3 ; RUN: FileCheck %s -check-prefix=Default
4 ; RUN: llc -mtriple=mipsel -O1 -relocation-model=static < %s | \
5 ; RUN: FileCheck %s -check-prefix=STATICO1
6 ; RUN: llc -mtriple=mipsel -disable-mips-df-forward-search=false \
7 ; RUN: -relocation-model=static < %s | FileCheck %s -check-prefix=FORWARD
8 ; RUN: llc -mtriple=mipsel -disable-mips-df-backward-search -relocation-model=pic \
9 ; RUN: -enable-shrink-wrap=false \
10 ; RUN: -disable-mips-df-succbb-search=false -disable-preheader-prot=true < %s | \
11 ; RUN: FileCheck %s -check-prefix=SUCCBB
13 define void @foo1() nounwind {
26 call void @foo2(i32 3) nounwind
30 declare void @foo2(i32)
32 ; Check that cvt.d.w goes into jalr's delay slot.
34 define void @foo3(i32 %a) nounwind {
36 ; Default-LABEL: foo3:
40 %conv = sitofp i32 %a to double
41 call void @foo4(double %conv) nounwind
45 declare void @foo4(double)
47 @g2 = external global i32
48 @g1 = external global i32
49 @g3 = external global i32
51 ; Check that branch delay slot can be filled with an instruction with operand
54 ; Default-LABEL: foo5:
57 define void @foo5(i32 %a) nounwind {
59 %0 = load i32, ptr @g2, align 4
60 %tobool = icmp eq i32 %a, 0
61 br i1 %tobool, label %if.else, label %if.then
64 %1 = load i32, ptr @g1, align 4
65 %add = add nsw i32 %1, %0
66 store i32 %add, ptr @g1, align 4
70 %2 = load i32, ptr @g3, align 4
71 %sub = sub nsw i32 %2, %0
72 store i32 %sub, ptr @g3, align 4
79 ; Check that delay slot filler can place mov.s or mov.d in delay slot.
81 ; Default-LABEL: foo6:
85 define void @foo6(float %a0, double %a1) nounwind {
87 call void @foo7(double %a1, float %a0) nounwind
91 declare void @foo7(double, float)
93 ; Check that a store can move past other memory instructions.
95 ; STATICO1-LABEL: foo8:
96 ; STATICO1: jalr ${{[0-9]+}}
97 ; STATICO1-NEXT: sw ${{[0-9]+}}, %lo(g1)
99 @foo9 = common global ptr null, align 4
101 define i32 @foo8(i32 %a) nounwind {
103 store i32 %a, ptr @g1, align 4
104 %0 = load ptr, ptr @foo9, align 4
105 call void %0() nounwind
106 %1 = load i32, ptr @g1, align 4
107 %add = add nsw i32 %1, %a
111 ; Test searchForward. Check that the second jal's slot is filled with another
112 ; instruction in the same block.
114 ; FORWARD-LABEL: foo10:
120 define void @foo10() nounwind {
122 tail call void @foo11() nounwind
123 tail call void @foo11() nounwind
124 store i32 0, ptr @g1, align 4
125 tail call void @foo11() nounwind
126 store i32 0, ptr @g1, align 4
130 declare void @foo11()
132 ; Check that delay slots of branches in both the entry block and loop body are
135 ; SUCCBB-LABEL: succbbs_loop1:
136 ; SUCCBB: blez $5, $BB
138 ; SUCCBB: bnez ${{[0-9]+}}, $BB
141 define i32 @succbbs_loop1(ptr nocapture %a, i32 %n) {
143 %cmp4 = icmp sgt i32 %n, 0
144 br i1 %cmp4, label %for.body, label %for.end
146 for.body: ; preds = %entry, %for.body
147 %s.06 = phi i32 [ %add, %for.body ], [ 0, %entry ]
148 %i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
149 %arrayidx = getelementptr inbounds i32, ptr %a, i32 %i.05
150 %0 = load i32, ptr %arrayidx, align 4
151 %add = add nsw i32 %0, %s.06
152 %inc = add nsw i32 %i.05, 1
153 %exitcond = icmp eq i32 %inc, %n
154 br i1 %exitcond, label %for.end, label %for.body
156 for.end: ; preds = %for.body, %entry
157 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
161 ; Check that the first branch has its slot filled.
163 ; SUCCBB-LABEL: succbbs_br1:
164 ; SUCCBB: beqz ${{[0-9]+}}, $BB
165 ; SUCCBB-NEXT: lw ${{[0-9]+}}, %got(foo101)(${{[0-9]+}})
167 define internal fastcc void @foo101() {
169 tail call void @foo100()
170 tail call void @foo100()
174 define void @succbbs_br1(i32 %a) {
176 %tobool = icmp eq i32 %a, 0
177 br i1 %tobool, label %if.end, label %if.then
179 if.then: ; preds = %entry
180 tail call fastcc void @foo101()
183 if.end: ; preds = %entry, %if.then
187 declare void @foo100()