1 ; RUN: opt -licm -basicaa < %s -S | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s
4 define void @f_0(i1 %p) nounwind ssp {
10 br i1 undef, label %if.then, label %for.cond.backedge
13 br i1 undef, label %for.end104, label %for.body
16 br i1 undef, label %if.then27, label %if.end.if.end.split_crit_edge.critedge
19 ; CHECK: tail call void @llvm.assume
20 tail call void @llvm.assume(i1 %p)
21 br label %for.body61.us
23 if.end.if.end.split_crit_edge.critedge:
27 br i1 undef, label %for.cond.backedge, label %for.body61.us
30 br i1 undef, label %for.cond.backedge, label %for.body61
36 define void @f_1(i1 %cond, i32* %ptr) {
39 ; CHECK: call void @llvm.assume(i1 %cond)
40 ; CHECK: %val = load i32, i32* %ptr
47 %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ]
48 call void @llvm.assume(i1 %cond)
49 %val = load i32, i32* %ptr
50 %x.inc = add i32 %x, %val
54 ; Can't hoist because the call may throw and the assume
56 define void @f_2(i1 %cond, i32* %ptr) {
60 ; CHECK: call void @llvm.assume(i1 %cond)
61 ; CHECK: %val = load i32, i32* %ptr
67 %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ]
69 call void @llvm.assume(i1 %cond)
70 %val = load i32, i32* %ptr
71 %x.inc = add i32 %x, %val
75 ; Note: resulting loop could be peeled and then hoisted, but
76 ; by default assume is captured in phi cycle.
77 define void @f_3(i1 %cond, i32* %ptr) {
80 ; CHECK: %val = load i32, i32* %ptr
82 ; CHECK: call void @llvm.assume(i1 %x.cmp)
88 %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ]
89 %x.cmp = phi i1 [%cond, %entry], [%cond.next, %loop]
90 call void @llvm.assume(i1 %x.cmp)
91 %val = load i32, i32* %ptr
92 %cond.next = icmp eq i32 %val, 5
93 %x.inc = add i32 %x, %val
98 declare void @maythrow()
99 declare void @llvm.assume(i1)