• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s  -O1  -S -loop-versioning-licm -licm -debug-only=loop-versioning-licm -disable-loop-unrolling -enable-new-pm=0 2>&1 | FileCheck %s
2; RUN: opt < %s  -S -passes='default<O1>,loop-versioning-licm,licm' --aa-pipeline=default -debug-only=loop-versioning-licm -disable-loop-unrolling 2>&1 | FileCheck %s
3; REQUIRES: asserts
4;
5; Test to confirm loop is a good candidate for LoopVersioningLICM
6; It also confirms invariant moved out of loop.
7;
8; CHECK: Loop: Loop at depth 2 containing: %for.body3.us<header><latch><exiting>
9; CHECK-NEXT:     Loop Versioning found to be beneficial
10;
11; CHECK: for.cond1.for.inc17_crit_edge.us.loopexit6:       ; preds = %for.body3.us
12; CHECK-NEXT: %add14.us.lcssa = phi float [ %add14.us, %for.body3.us ]
13; CHECK-NEXT: store float %add14.us.lcssa, float* %arrayidx.us, align 4, !alias.scope !0, !noalias !0
14; CHECK-NEXT: br label %for.cond1.for.inc17_crit_edge.us
15;
16define i32 @foo(float* nocapture %var2, float** nocapture readonly %var3, i32 %itr) #0 {
17entry:
18  %cmp38 = icmp sgt i32 %itr, 1
19  br i1 %cmp38, label %for.body3.lr.ph.us, label %for.end19
20
21for.body3.us:                                     ; preds = %for.body3.us, %for.body3.lr.ph.us
22  %0 = phi float [ %.pre, %for.body3.lr.ph.us ], [ %add14.us, %for.body3.us ]
23  %indvars.iv = phi i64 [ 1, %for.body3.lr.ph.us ], [ %indvars.iv.next, %for.body3.us ]
24  %1 = trunc i64 %indvars.iv to i32
25  %conv.us = sitofp i32 %1 to float
26  %add.us = fadd float %conv.us, %0
27  %arrayidx7.us = getelementptr inbounds float, float* %3, i64 %indvars.iv
28  store float %add.us, float* %arrayidx7.us, align 4
29  %2 = load float, float* %arrayidx.us, align 4
30  %add14.us = fadd float %2, %add.us
31  store float %add14.us, float* %arrayidx.us, 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.cond1.for.inc17_crit_edge.us, label %for.body3.us
36
37for.body3.lr.ph.us:                               ; preds = %entry, %for.cond1.for.inc17_crit_edge.us
38  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %for.cond1.for.inc17_crit_edge.us ], [ 1, %entry ]
39  %arrayidx.us = getelementptr inbounds float, float* %var2, i64 %indvars.iv40
40  %arrayidx6.us = getelementptr inbounds float*, float** %var3, i64 %indvars.iv40
41  %3 = load float*, float** %arrayidx6.us, align 8
42  %.pre = load float, float* %arrayidx.us, align 4
43  br label %for.body3.us
44
45for.cond1.for.inc17_crit_edge.us:                 ; preds = %for.body3.us
46  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
47  %lftr.wideiv42 = trunc i64 %indvars.iv.next41 to i32
48  %exitcond43 = icmp eq i32 %lftr.wideiv42, %itr
49  br i1 %exitcond43, label %for.end19, label %for.body3.lr.ph.us
50
51for.end19:                                        ; preds = %for.cond1.for.inc17_crit_edge.us, %entry
52  ret i32 0
53}
54