1; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=CHECK
2; RUN: llc < %s -mtriple=x86_64-linux -sink-insts-to-avoid-spills | FileCheck %s -check-prefix=SINK
3
4; Ensure that we sink copy-like instructions into loops to avoid register
5; spills.
6
7; CHECK: Spill
8; SINK-NOT: Spill
9
10%struct.A = type { i32, i32, i32, i32, i32, i32 }
11
12define void @_Z1fPhP1A(i8* nocapture readonly %input, %struct.A* %a) {
13  %1 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 0
14  %2 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 1
15  %3 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 2
16  %4 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 3
17  %5 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 4
18  %6 = getelementptr inbounds %struct.A, %struct.A* %a, i64 0, i32 5
19  br label %.backedge
20
21.backedge:
22  %.0 = phi i8* [ %input, %0 ], [ %7, %.backedge.backedge ]
23  %7 = getelementptr inbounds i8, i8* %.0, i64 1
24  %8 = load i8, i8* %7, align 1
25  switch i8 %8, label %.backedge.backedge [
26    i8 0, label %9
27    i8 10, label %10
28    i8 20, label %11
29    i8 30, label %12
30    i8 40, label %13
31    i8 50, label %14
32  ]
33
34; <label>:9
35  tail call void @_Z6assignPj(i32* %1)
36  br label %.backedge.backedge
37
38; <label>:10
39  tail call void @_Z6assignPj(i32* %2)
40  br label %.backedge.backedge
41
42.backedge.backedge:
43  br label %.backedge
44
45; <label>:11
46  tail call void @_Z6assignPj(i32* %3)
47  br label %.backedge.backedge
48
49; <label>:12
50  tail call void @_Z6assignPj(i32* %4)
51  br label %.backedge.backedge
52
53; <label>:13
54  tail call void @_Z6assignPj(i32* %5)
55  br label %.backedge.backedge
56
57; <label>:14
58  tail call void @_Z6assignPj(i32* %6)
59  br label %.backedge.backedge
60}
61
62declare void @_Z6assignPj(i32*)
63