1 ; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s
3 ; A MOV32ri is inside a loop, it has two successors, one successor is inside the
4 ; same loop, the other successor is outside the loop. We should be able to sink
5 ; MOV32ri outside the loop.
7 define i32 @sink_succ(i32 %argc, i8** nocapture %argv) nounwind uwtable ssp {
8 ; CHECK-LABEL: sink_succ
9 ; CHECK: [[OUTER_LN1:LBB0_[0-9]+]]: ## %preheader
12 ; CHECK: jne [[OUTER_LN1]]
14 ; CHECK: [[LN2:LBB0_[0-9]+]]: ## %for.body2
21 %i.127 = phi i32 [ 0, %entry ], [ %inc9, %exit ]
22 br label %for.body1.lr
25 %iv30 = phi i32 [ 1, %preheader ], [ %iv.next31, %for.inc40.i ]
29 %iv.i = phi i64 [ 0, %for.body1.lr ], [ %iv.next.i, %for.body1 ]
30 %iv.next.i = add i64 %iv.i, 1
31 %lftr.wideiv32 = trunc i64 %iv.next.i to i32
32 %exitcond33 = icmp eq i32 %lftr.wideiv32, %iv30
33 br i1 %exitcond33, label %for.inc40.i, label %for.body1
36 %iv.next31 = add i32 %iv30, 1
37 %exitcond49.i = icmp eq i32 %iv.next31, 32
38 br i1 %exitcond49.i, label %exit, label %for.body1.lr
41 %inc9 = add nsw i32 %i.127, 1
42 %exitcond34 = icmp eq i32 %inc9, 10
43 br i1 %exitcond34, label %for.body2, label %preheader
46 %iv = phi i64 [ %iv.next, %for.body2 ], [ 0, %exit ]
47 %iv.next = add i64 %iv, 1
48 %lftr.wideiv = trunc i64 %iv.next to i32
49 %exitcond = icmp eq i32 %lftr.wideiv, 2048
50 br i1 %exitcond, label %for.end20, label %for.body2
56 define i32 @sink_out_of_loop(i32 %n, i32* %output) {
57 ; CHECK-LABEL: sink_out_of_loop:
62 %i = phi i32 [ 0, %entry ], [ %i2, %loop ]
64 %addr = getelementptr i32, i32* %output, i32 %i
65 store i32 %i, i32* %addr
67 %exit_cond = icmp sge i32 %i2, %n
68 br i1 %exit_cond, label %exit, label %loop
72 ; CHECK: imull %eax, %eax