xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/phielim-split.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -verify-machineinstrs -no-phi-elim-live-out-early-exit | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.8.0"
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; The critical edge from for.cond to if.end2 should be split to avoid injecting
5*9880d681SAndroid Build Coastguard Worker; copies into the loop. The use of %b after the loop causes interference that
6*9880d681SAndroid Build Coastguard Worker; makes a copy necessary.
7*9880d681SAndroid Build Coastguard Worker; <rdar://problem/11561842>
8*9880d681SAndroid Build Coastguard Worker;
9*9880d681SAndroid Build Coastguard Worker; CHECK: split_loop_exit
10*9880d681SAndroid Build Coastguard Worker; CHECK: %for.cond
11*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
12*9880d681SAndroid Build Coastguard Worker; CHECK: je
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine i32 @split_loop_exit(i32 %a, i32 %b, i8* nocapture %p) nounwind uwtable readonly ssp {
15*9880d681SAndroid Build Coastguard Workerentry:
16*9880d681SAndroid Build Coastguard Worker  %cmp = icmp sgt i32 %a, 10
17*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %for.cond, label %if.end2
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerfor.cond:                                         ; preds = %entry, %for.cond
20*9880d681SAndroid Build Coastguard Worker  %p.addr.0 = phi i8* [ %incdec.ptr, %for.cond ], [ %p, %entry ]
21*9880d681SAndroid Build Coastguard Worker  %incdec.ptr = getelementptr inbounds i8, i8* %p.addr.0, i64 1
22*9880d681SAndroid Build Coastguard Worker  %0 = load i8, i8* %p.addr.0, align 1
23*9880d681SAndroid Build Coastguard Worker  %tobool = icmp eq i8 %0, 0
24*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %for.cond, label %if.end2
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerif.end2:                                          ; preds = %for.cond, %entry
27*9880d681SAndroid Build Coastguard Worker  %r.0 = phi i32 [ %a, %entry ], [ %b, %for.cond ]
28*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %r.0, %b
29*9880d681SAndroid Build Coastguard Worker  ret i32 %add
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; CHECK: split_live_out
33*9880d681SAndroid Build Coastguard Worker; CHECK: %while.body
34*9880d681SAndroid Build Coastguard Worker; CHECK: cmp
35*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ja
36*9880d681SAndroid Build Coastguard Workerdefine i8* @split_live_out(i32 %value, i8* %target) nounwind uwtable readonly ssp {
37*9880d681SAndroid Build Coastguard Workerentry:
38*9880d681SAndroid Build Coastguard Worker  %cmp10 = icmp ugt i32 %value, 127
39*9880d681SAndroid Build Coastguard Worker  br i1 %cmp10, label %while.body.preheader, label %while.end
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerwhile.body.preheader:                             ; preds = %entry
42*9880d681SAndroid Build Coastguard Worker  br label %while.body
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerwhile.body:                                       ; preds = %while.body.preheader, %while.body
45*9880d681SAndroid Build Coastguard Worker  %target.addr.012 = phi i8* [ %incdec.ptr, %while.body ], [ %target, %while.body.preheader ]
46*9880d681SAndroid Build Coastguard Worker  %value.addr.011 = phi i32 [ %shr, %while.body ], [ %value, %while.body.preheader ]
47*9880d681SAndroid Build Coastguard Worker  %or = or i32 %value.addr.011, 128
48*9880d681SAndroid Build Coastguard Worker  %conv = trunc i32 %or to i8
49*9880d681SAndroid Build Coastguard Worker  store i8 %conv, i8* %target.addr.012, align 1
50*9880d681SAndroid Build Coastguard Worker  %shr = lshr i32 %value.addr.011, 7
51*9880d681SAndroid Build Coastguard Worker  %incdec.ptr = getelementptr inbounds i8, i8* %target.addr.012, i64 1
52*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ugt i32 %value.addr.011, 16383
53*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %while.body, label %while.end.loopexit
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Workerwhile.end.loopexit:                               ; preds = %while.body
56*9880d681SAndroid Build Coastguard Worker  %incdec.ptr.lcssa = phi i8* [ %incdec.ptr, %while.body ]
57*9880d681SAndroid Build Coastguard Worker  %shr.lcssa = phi i32 [ %shr, %while.body ]
58*9880d681SAndroid Build Coastguard Worker  br label %while.end
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Workerwhile.end:                                        ; preds = %while.end.loopexit, %entry
61*9880d681SAndroid Build Coastguard Worker  %target.addr.0.lcssa = phi i8* [ %target, %entry ], [ %incdec.ptr.lcssa, %while.end.loopexit ]
62*9880d681SAndroid Build Coastguard Worker  %value.addr.0.lcssa = phi i32 [ %value, %entry ], [ %shr.lcssa, %while.end.loopexit ]
63*9880d681SAndroid Build Coastguard Worker  %conv1 = trunc i32 %value.addr.0.lcssa to i8
64*9880d681SAndroid Build Coastguard Worker  store i8 %conv1, i8* %target.addr.0.lcssa, align 1
65*9880d681SAndroid Build Coastguard Worker  %incdec.ptr3 = getelementptr inbounds i8, i8* %target.addr.0.lcssa, i64 1
66*9880d681SAndroid Build Coastguard Worker  ret i8* %incdec.ptr3
67*9880d681SAndroid Build Coastguard Worker}
68