1 ; RUN: llc < %s -verify-machineinstrs -no-phi-elim-live-out-early-exit | FileCheck %s
2 target triple = "x86_64-apple-macosx10.8.0"
4 ; The critical edge from for.cond to if.end2 should be split to avoid injecting
5 ; copies into the loop. The use of %b after the loop causes interference that
6 ; makes a copy necessary.
7 ; <rdar://problem/11561842>
9 ; CHECK: split_loop_exit
14 define i32 @split_loop_exit(i32 %a, i32 %b, i8* nocapture %p) nounwind uwtable readonly ssp {
16 %cmp = icmp sgt i32 %a, 10
17 br i1 %cmp, label %for.cond, label %if.end2
19 for.cond: ; preds = %entry, %for.cond
20 %p.addr.0 = phi i8* [ %incdec.ptr, %for.cond ], [ %p, %entry ]
21 %incdec.ptr = getelementptr inbounds i8, i8* %p.addr.0, i64 1
22 %0 = load i8, i8* %p.addr.0, align 1
23 %tobool = icmp eq i8 %0, 0
24 br i1 %tobool, label %for.cond, label %if.end2
26 if.end2: ; preds = %for.cond, %entry
27 %r.0 = phi i32 [ %a, %entry ], [ %b, %for.cond ]
28 %add = add nsw i32 %r.0, %b
32 ; CHECK: split_live_out
36 define i8* @split_live_out(i32 %value, i8* %target) nounwind uwtable readonly ssp {
38 %cmp10 = icmp ugt i32 %value, 127
39 br i1 %cmp10, label %while.body.preheader, label %while.end
41 while.body.preheader: ; preds = %entry
44 while.body: ; preds = %while.body.preheader, %while.body
45 %target.addr.012 = phi i8* [ %incdec.ptr, %while.body ], [ %target, %while.body.preheader ]
46 %value.addr.011 = phi i32 [ %shr, %while.body ], [ %value, %while.body.preheader ]
47 %or = or i32 %value.addr.011, 128
48 %conv = trunc i32 %or to i8
49 store i8 %conv, i8* %target.addr.012, align 1
50 %shr = lshr i32 %value.addr.011, 7
51 %incdec.ptr = getelementptr inbounds i8, i8* %target.addr.012, i64 1
52 %cmp = icmp ugt i32 %value.addr.011, 16383
53 br i1 %cmp, label %while.body, label %while.end.loopexit
55 while.end.loopexit: ; preds = %while.body
56 %incdec.ptr.lcssa = phi i8* [ %incdec.ptr, %while.body ]
57 %shr.lcssa = phi i32 [ %shr, %while.body ]
60 while.end: ; preds = %while.end.loopexit, %entry
61 %target.addr.0.lcssa = phi i8* [ %target, %entry ], [ %incdec.ptr.lcssa, %while.end.loopexit ]
62 %value.addr.0.lcssa = phi i32 [ %value, %entry ], [ %shr.lcssa, %while.end.loopexit ]
63 %conv1 = trunc i32 %value.addr.0.lcssa to i8
64 store i8 %conv1, i8* %target.addr.0.lcssa, align 1
65 %incdec.ptr3 = getelementptr inbounds i8, i8* %target.addr.0.lcssa, i64 1