[mips] Define class MemDefsUses.
[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 ; RUN: llc -march=mipsel -O1 -relocation-model=static < %s | \
4 ; RUN: FileCheck %s -check-prefix=STATICO1
5
6 define void @foo1() nounwind {
7 entry:
8 ; Default:     jalr 
9 ; Default-NOT: nop 
10 ; Default:     jr 
11 ; Default-NOT: nop
12 ; Default:     .end
13 ; None: jalr 
14 ; None: nop 
15 ; None: jr 
16 ; None: nop
17 ; None: .end
18
19   tail call void @foo2(i32 3) nounwind
20   ret void
21 }
22
23 declare void @foo2(i32)
24
25 ; Check that cvt.d.w goes into jalr's delay slot.
26 ;
27 define void @foo3(i32 %a) nounwind {
28 entry:
29 ; Default:     foo3:
30 ; Default:     jalr
31 ; Default:     cvt.d.w
32
33   %conv = sitofp i32 %a to double
34   tail call void @foo4(double %conv) nounwind
35   ret void
36 }
37
38 declare void @foo4(double)
39
40 @g2 = external global i32
41 @g1 = external global i32
42 @g3 = external global i32
43
44 ; Check that branch delay slot can be filled with an instruction with operand
45 ; $1.
46 ;
47 ; Default:     foo5:
48 ; Default-NOT: nop
49
50 define void @foo5(i32 %a) nounwind {
51 entry:
52   %0 = load i32* @g2, align 4
53   %tobool = icmp eq i32 %a, 0
54   br i1 %tobool, label %if.else, label %if.then
55
56 if.then:
57   %1 = load i32* @g1, align 4
58   %add = add nsw i32 %1, %0
59   store i32 %add, i32* @g1, align 4
60   br label %if.end
61
62 if.else:
63   %2 = load i32* @g3, align 4
64   %sub = sub nsw i32 %2, %0
65   store i32 %sub, i32* @g3, align 4
66   br label %if.end
67
68 if.end:
69   ret void
70 }
71
72 ; Check that delay slot filler can place mov.s or mov.d in delay slot.
73 ;
74 ; Default:     foo6:
75 ; Default-NOT: nop
76
77 define void @foo6(float %a0, double %a1) nounwind {
78 entry:
79   tail call void @foo7(double %a1, float %a0) nounwind
80   ret void
81 }
82
83 declare void @foo7(double, float)
84
85 ; Check that a store can move past other memory instructions.
86 ;
87 ; STATICO1:      foo8:
88 ; STATICO1:      jalr ${{[0-9]+}}
89 ; STATICO1-NEXT: sw ${{[0-9]+}}, %lo(g1)
90
91 @foo9 = common global void ()* null, align 4
92
93 define i32 @foo8(i32 %a) nounwind {
94 entry:
95   store i32 %a, i32* @g1, align 4
96   %0 = load void ()** @foo9, align 4
97   tail call void %0() nounwind
98   %1 = load i32* @g1, align 4
99   %add = add nsw i32 %1, %a
100   ret i32 %add
101 }