1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s
4 ; A MOV32ri is inside a loop, it has two successors, one successor is inside the
5 ; same loop, the other successor is outside the loop. We should be able to sink
6 ; MOV32ri outside the loop.
8 define i32 @sink_succ(i32 %argc, ptr nocapture %argv) nounwind uwtable ssp {
9 ; CHECK-LABEL: sink_succ:
10 ; CHECK: ## %bb.0: ## %entry
11 ; CHECK-NEXT: xorl %eax, %eax
12 ; CHECK-NEXT: .p2align 4
13 ; CHECK-NEXT: LBB0_1: ## %preheader
14 ; CHECK-NEXT: ## =>This Loop Header: Depth=1
15 ; CHECK-NEXT: ## Child Loop BB0_2 Depth 2
16 ; CHECK-NEXT: ## Child Loop BB0_3 Depth 3
17 ; CHECK-NEXT: movl $1, %ecx
18 ; CHECK-NEXT: .p2align 4
19 ; CHECK-NEXT: LBB0_2: ## %for.body1.lr
20 ; CHECK-NEXT: ## Parent Loop BB0_1 Depth=1
21 ; CHECK-NEXT: ## => This Loop Header: Depth=2
22 ; CHECK-NEXT: ## Child Loop BB0_3 Depth 3
23 ; CHECK-NEXT: movl %ecx, %edx
24 ; CHECK-NEXT: .p2align 4
25 ; CHECK-NEXT: LBB0_3: ## %for.body1
26 ; CHECK-NEXT: ## Parent Loop BB0_1 Depth=1
27 ; CHECK-NEXT: ## Parent Loop BB0_2 Depth=2
28 ; CHECK-NEXT: ## => This Inner Loop Header: Depth=3
29 ; CHECK-NEXT: decl %edx
30 ; CHECK-NEXT: jne LBB0_3
31 ; CHECK-NEXT: ## %bb.4: ## %for.inc40.i
32 ; CHECK-NEXT: ## in Loop: Header=BB0_2 Depth=2
33 ; CHECK-NEXT: incl %ecx
34 ; CHECK-NEXT: cmpl $32, %ecx
35 ; CHECK-NEXT: jne LBB0_2
36 ; CHECK-NEXT: ## %bb.5: ## %exit
37 ; CHECK-NEXT: ## in Loop: Header=BB0_1 Depth=1
38 ; CHECK-NEXT: incl %eax
39 ; CHECK-NEXT: cmpl $10, %eax
40 ; CHECK-NEXT: jne LBB0_1
41 ; CHECK-NEXT: ## %bb.6: ## %for.body2.preheader
42 ; CHECK-NEXT: movl $2048, %eax ## imm = 0x800
43 ; CHECK-NEXT: .p2align 4
44 ; CHECK-NEXT: LBB0_7: ## %for.body2
45 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
46 ; CHECK-NEXT: decl %eax
47 ; CHECK-NEXT: jne LBB0_7
48 ; CHECK-NEXT: ## %bb.8: ## %for.end20
49 ; CHECK-NEXT: xorl %eax, %eax
55 %i.127 = phi i32 [ 0, %entry ], [ %inc9, %exit ]
56 br label %for.body1.lr
59 %iv30 = phi i32 [ 1, %preheader ], [ %iv.next31, %for.inc40.i ]
63 %iv.i = phi i64 [ 0, %for.body1.lr ], [ %iv.next.i, %for.body1 ]
64 %iv.next.i = add i64 %iv.i, 1
65 %lftr.wideiv32 = trunc i64 %iv.next.i to i32
66 %exitcond33 = icmp eq i32 %lftr.wideiv32, %iv30
67 br i1 %exitcond33, label %for.inc40.i, label %for.body1
70 %iv.next31 = add i32 %iv30, 1
71 %exitcond49.i = icmp eq i32 %iv.next31, 32
72 br i1 %exitcond49.i, label %exit, label %for.body1.lr
75 %inc9 = add nsw i32 %i.127, 1
76 %exitcond34 = icmp eq i32 %inc9, 10
77 br i1 %exitcond34, label %for.body2, label %preheader
80 %iv = phi i64 [ %iv.next, %for.body2 ], [ 0, %exit ]
81 %iv.next = add i64 %iv, 1
82 %lftr.wideiv = trunc i64 %iv.next to i32
83 %exitcond = icmp eq i32 %lftr.wideiv, 2048
84 br i1 %exitcond, label %for.end20, label %for.body2
90 define i32 @sink_out_of_loop(i32 %n, ptr %output) {
91 ; CHECK-LABEL: sink_out_of_loop:
92 ; CHECK: ## %bb.0: ## %entry
93 ; CHECK-NEXT: xorl %ecx, %ecx
94 ; CHECK-NEXT: .p2align 4
95 ; CHECK-NEXT: LBB1_1: ## %loop
96 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
97 ; CHECK-NEXT: movl %ecx, %eax
98 ; CHECK-NEXT: movl %ecx, (%rsi,%rcx,4)
99 ; CHECK-NEXT: incq %rcx
100 ; CHECK-NEXT: cmpl %edi, %ecx
101 ; CHECK-NEXT: jl LBB1_1
102 ; CHECK-NEXT: ## %bb.2: ## %exit
103 ; CHECK-NEXT: imull %eax, %eax
109 %i = phi i32 [ 0, %entry ], [ %i2, %loop ]
111 %addr = getelementptr i32, ptr %output, i32 %i
112 store i32 %i, ptr %addr
114 %exit_cond = icmp sge i32 %i2, %n
115 br i1 %exit_cond, label %exit, label %loop