1 ; RUN: opt < %s -S -passes='default<O3>,loop-versioning-licm' -debug-only=loop-versioning-licm 2>&1 | FileCheck %s
2 ; RUN: opt < %s -S -passes='loop-versioning-licm' -debug-only=loop-versioning-licm 2>&1 | FileCheck %s
5 ; Test to confirm loop is not a candidate for LoopVersioningLICM.
7 ; CHECK: Loop: Loop at depth 2 containing: %for.body3<header><latch><exiting>
8 ; CHECK-NEXT: LAA: Runtime check not found !!
9 ; CHECK-NEXT: Loop instructions not suitable for LoopVersioningLICM
11 define i32 @foo(ptr nocapture %var1, i32 %itr) #0 {
13 %cmp18 = icmp eq i32 %itr, 0
14 br i1 %cmp18, label %for.end8, label %for.cond1.preheader
16 for.cond1.preheader: ; preds = %entry, %for.inc6
17 %j.020 = phi i32 [ %j.1.lcssa, %for.inc6 ], [ 0, %entry ]
18 %i.019 = phi i32 [ %inc7, %for.inc6 ], [ 0, %entry ]
19 %cmp216 = icmp ult i32 %j.020, %itr
20 br i1 %cmp216, label %for.body3.lr.ph, label %for.inc6
22 for.body3.lr.ph: ; preds = %for.cond1.preheader
23 %0 = zext i32 %j.020 to i64
26 for.body3: ; preds = %for.body3, %for.body3.lr.ph
27 %indvars.iv = phi i64 [ %0, %for.body3.lr.ph ], [ %indvars.iv.next, %for.body3 ]
28 %arrayidx = getelementptr inbounds i32, ptr %var1, i64 %indvars.iv
29 %1 = load i32, ptr %arrayidx, align 4
30 %add = add nsw i32 %1, %itr
31 store i32 %add, ptr %arrayidx, align 4
32 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
33 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
34 %exitcond = icmp eq i32 %lftr.wideiv, %itr
35 br i1 %exitcond, label %for.inc6, label %for.body3
37 for.inc6: ; preds = %for.body3, %for.cond1.preheader
38 %j.1.lcssa = phi i32 [ %j.020, %for.cond1.preheader ], [ %itr, %for.body3 ]
39 %inc7 = add nuw i32 %i.019, 1
40 %exitcond21 = icmp eq i32 %inc7, %itr
41 br i1 %exitcond21, label %for.end8, label %for.cond1.preheader
43 for.end8: ; preds = %for.inc6, %entry