• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -verify-machineinstrs -no-phi-elim-live-out-early-exit | FileCheck %s
2target triple = "x86_64-apple-macosx10.8.0"
3
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>
8;
9; CHECK: split_loop_exit
10; CHECK: %for.cond
11; CHECK-NOT: mov
12; CHECK: je
13
14define i32 @split_loop_exit(i32 %a, i32 %b, i8* nocapture %p) nounwind uwtable readonly ssp {
15entry:
16  %cmp = icmp sgt i32 %a, 10
17  br i1 %cmp, label %for.cond, label %if.end2
18
19for.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
25
26if.end2:                                          ; preds = %for.cond, %entry
27  %r.0 = phi i32 [ %a, %entry ], [ %b, %for.cond ]
28  %add = add nsw i32 %r.0, %b
29  ret i32 %add
30}
31
32; CHECK: split_live_out
33; CHECK: %while.body
34; CHECK: cmp
35; CHECK-NEXT: ja
36define i8* @split_live_out(i32 %value, i8* %target) nounwind uwtable readonly ssp {
37entry:
38  %cmp10 = icmp ugt i32 %value, 127
39  br i1 %cmp10, label %while.body.preheader, label %while.end
40
41while.body.preheader:                             ; preds = %entry
42  br label %while.body
43
44while.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
54
55while.end.loopexit:                               ; preds = %while.body
56  %incdec.ptr.lcssa = phi i8* [ %incdec.ptr, %while.body ]
57  %shr.lcssa = phi i32 [ %shr, %while.body ]
58  br label %while.end
59
60while.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
66  ret i8* %incdec.ptr3
67}
68