[mips] Fix delay slot filler so that instructions with register operand $1 are
[oota-llvm.git] / test / CodeGen / Mips / brdelayslot.ll
1 ; RUN: llc -march=mipsel -O0 < %s | FileCheck %s -check-prefix=None
2 ; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=Default
3
4 define void @foo1() nounwind {
5 entry:
6 ; Default:     jalr 
7 ; Default-NOT: nop 
8 ; Default:     jr 
9 ; Default-NOT: nop
10 ; Default:     .end
11 ; None: jalr 
12 ; None: nop 
13 ; None: jr 
14 ; None: nop
15 ; None: .end
16
17   tail call void @foo2(i32 3) nounwind
18   ret void
19 }
20
21 declare void @foo2(i32)
22
23 ; Check that cvt.d.w goes into jalr's delay slot.
24 ;
25 define void @foo3(i32 %a) nounwind {
26 entry:
27 ; Default:     foo3:
28 ; Default:     jalr
29 ; Default:     cvt.d.w
30
31   %conv = sitofp i32 %a to double
32   tail call void @foo4(double %conv) nounwind
33   ret void
34 }
35
36 declare void @foo4(double)
37
38 @g2 = external global i32
39 @g1 = external global i32
40 @g3 = external global i32
41
42 ; Check that branch delay slot can be filled with an instruction with operand
43 ; $1.
44 ;
45 ; Default:     foo5:
46 ; Default-NOT: nop
47
48 define void @foo5(i32 %a) nounwind {
49 entry:
50   %0 = load i32* @g2, align 4
51   %tobool = icmp eq i32 %a, 0
52   br i1 %tobool, label %if.else, label %if.then
53
54 if.then:
55   %1 = load i32* @g1, align 4
56   %add = add nsw i32 %1, %0
57   store i32 %add, i32* @g1, align 4
58   br label %if.end
59
60 if.else:
61   %2 = load i32* @g3, align 4
62   %sub = sub nsw i32 %2, %0
63   store i32 %sub, i32* @g3, align 4
64   br label %if.end
65
66 if.end:
67   ret void
68 }
69