xref: /aosp_15_r20/external/llvm/test/Transforms/LoopVersioningLICM/metadata.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s  -O1  -S -loop-versioning-licm -licm 2>&1 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @without_metadata(
4*9880d681SAndroid Build Coastguard Workerdefine i32 @without_metadata(i32* nocapture %var1, i32* nocapture readnone %var2, i32* nocapture %var3, i32 %itr) #0 {
5*9880d681SAndroid Build Coastguard Workerentry:
6*9880d681SAndroid Build Coastguard Worker  %cmp14 = icmp eq i32 %itr, 0
7*9880d681SAndroid Build Coastguard Worker  br i1 %cmp14, label %for.end13, label %for.cond1.preheader.preheader
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerfor.cond1.preheader.preheader:                    ; preds = %entry
10*9880d681SAndroid Build Coastguard Worker  br label %for.cond1.preheader
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerfor.cond1.preheader:                              ; preds = %for.cond1.preheader.preheader, %for.inc11
13*9880d681SAndroid Build Coastguard Worker  %j.016 = phi i32 [ %j.1.lcssa, %for.inc11 ], [ 0, %for.cond1.preheader.preheader ]
14*9880d681SAndroid Build Coastguard Worker  %i.015 = phi i32 [ %inc12, %for.inc11 ], [ 0, %for.cond1.preheader.preheader ]
15*9880d681SAndroid Build Coastguard Worker  %cmp212 = icmp ult i32 %j.016, %itr
16*9880d681SAndroid Build Coastguard Worker  br i1 %cmp212, label %for.body3.lr.ph, label %for.inc11
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerfor.body3.lr.ph:                                  ; preds = %for.cond1.preheader
19*9880d681SAndroid Build Coastguard Worker  %add = add i32 %i.015, %itr
20*9880d681SAndroid Build Coastguard Worker  %idxprom6 = zext i32 %i.015 to i64
21*9880d681SAndroid Build Coastguard Worker  %arrayidx7 = getelementptr inbounds i32, i32* %var3, i64 %idxprom6
22*9880d681SAndroid Build Coastguard Worker  br label %for.body3
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerfor.body3:                                        ; preds = %for.body3.lr.ph, %for.body3
25*9880d681SAndroid Build Coastguard Worker  %j.113 = phi i32 [ %j.016, %for.body3.lr.ph ], [ %inc, %for.body3 ]
26*9880d681SAndroid Build Coastguard Worker  %idxprom = zext i32 %j.113 to i64
27*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds i32, i32* %var1, i64 %idxprom
28*9880d681SAndroid Build Coastguard Worker; CHECK: store i32 %add, i32* %arrayidx, align 4, !alias.scope {{.*}}, !noalias {{.*}}
29*9880d681SAndroid Build Coastguard Worker  store i32 %add, i32* %arrayidx, align 4
30*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %arrayidx7, align 4
31*9880d681SAndroid Build Coastguard Worker  %add8 = add nsw i32 %0, %add
32*9880d681SAndroid Build Coastguard Worker  store i32 %add8, i32* %arrayidx7, align 4
33*9880d681SAndroid Build Coastguard Worker  %inc = add nuw i32 %j.113, 1
34*9880d681SAndroid Build Coastguard Worker  %cmp2 = icmp ult i32 %inc, %itr
35*9880d681SAndroid Build Coastguard Worker  br i1 %cmp2, label %for.body3, label %for.inc11.loopexit
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerfor.inc11.loopexit:                               ; preds = %for.body3
38*9880d681SAndroid Build Coastguard Worker  br label %for.inc11
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerfor.inc11:                                        ; preds = %for.inc11.loopexit, %for.cond1.preheader
41*9880d681SAndroid Build Coastguard Worker  %j.1.lcssa = phi i32 [ %j.016, %for.cond1.preheader ], [ %itr, %for.inc11.loopexit ]
42*9880d681SAndroid Build Coastguard Worker  %inc12 = add nuw i32 %i.015, 1
43*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ult i32 %inc12, %itr
44*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %for.cond1.preheader, label %for.end13.loopexit
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workerfor.end13.loopexit:                               ; preds = %for.inc11
47*9880d681SAndroid Build Coastguard Worker  br label %for.end13
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerfor.end13:                                        ; preds = %for.end13.loopexit, %entry
50*9880d681SAndroid Build Coastguard Worker  ret i32 0
51*9880d681SAndroid Build Coastguard Worker}
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @with_metadata(
54*9880d681SAndroid Build Coastguard Workerdefine i32 @with_metadata(i32* nocapture %var1, i32* nocapture readnone %var2, i32* nocapture %var3, i32 %itr) #0 {
55*9880d681SAndroid Build Coastguard Workerentry:
56*9880d681SAndroid Build Coastguard Worker  %cmp14 = icmp eq i32 %itr, 0
57*9880d681SAndroid Build Coastguard Worker  br i1 %cmp14, label %for.end13, label %for.cond1.preheader.preheader
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Workerfor.cond1.preheader.preheader:                    ; preds = %entry
60*9880d681SAndroid Build Coastguard Worker  br label %for.cond1.preheader
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Workerfor.cond1.preheader:                              ; preds = %for.cond1.preheader.preheader, %for.inc11
63*9880d681SAndroid Build Coastguard Worker  %j.016 = phi i32 [ %j.1.lcssa, %for.inc11 ], [ 0, %for.cond1.preheader.preheader ]
64*9880d681SAndroid Build Coastguard Worker  %i.015 = phi i32 [ %inc12, %for.inc11 ], [ 0, %for.cond1.preheader.preheader ]
65*9880d681SAndroid Build Coastguard Worker  %cmp212 = icmp ult i32 %j.016, %itr
66*9880d681SAndroid Build Coastguard Worker  br i1 %cmp212, label %for.body3.lr.ph, label %for.inc11
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerfor.body3.lr.ph:                                  ; preds = %for.cond1.preheader
69*9880d681SAndroid Build Coastguard Worker  %add = add i32 %i.015, %itr
70*9880d681SAndroid Build Coastguard Worker  %idxprom6 = zext i32 %i.015 to i64
71*9880d681SAndroid Build Coastguard Worker  %arrayidx7 = getelementptr inbounds i32, i32* %var3, i64 %idxprom6
72*9880d681SAndroid Build Coastguard Worker  br label %for.body3
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Workerfor.body3:                                        ; preds = %for.body3.lr.ph, %for.body3
75*9880d681SAndroid Build Coastguard Worker  %j.113 = phi i32 [ %j.016, %for.body3.lr.ph ], [ %inc, %for.body3 ]
76*9880d681SAndroid Build Coastguard Worker  %idxprom = zext i32 %j.113 to i64
77*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds i32, i32* %var1, i64 %idxprom
78*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: store i32 %add, i32* %arrayidx, align 4, !alias.scope {{.*}}, !noalias {{.*}}
79*9880d681SAndroid Build Coastguard Worker  store i32 %add, i32* %arrayidx, align 4
80*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %arrayidx7, align 4
81*9880d681SAndroid Build Coastguard Worker  %add8 = add nsw i32 %0, %add
82*9880d681SAndroid Build Coastguard Worker  store i32 %add8, i32* %arrayidx7, align 4
83*9880d681SAndroid Build Coastguard Worker  %inc = add nuw i32 %j.113, 1
84*9880d681SAndroid Build Coastguard Worker  %cmp2 = icmp ult i32 %inc, %itr
85*9880d681SAndroid Build Coastguard Worker  br i1 %cmp2, label %for.body3, label %for.inc11.loopexit, !llvm.loop !0
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Workerfor.inc11.loopexit:                               ; preds = %for.body3
88*9880d681SAndroid Build Coastguard Worker  br label %for.inc11
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard Workerfor.inc11:                                        ; preds = %for.inc11.loopexit, %for.cond1.preheader
91*9880d681SAndroid Build Coastguard Worker  %j.1.lcssa = phi i32 [ %j.016, %for.cond1.preheader ], [ %itr, %for.inc11.loopexit ]
92*9880d681SAndroid Build Coastguard Worker  %inc12 = add nuw i32 %i.015, 1
93*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ult i32 %inc12, %itr
94*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %for.cond1.preheader, label %for.end13.loopexit
95*9880d681SAndroid Build Coastguard Worker
96*9880d681SAndroid Build Coastguard Workerfor.end13.loopexit:                               ; preds = %for.inc11
97*9880d681SAndroid Build Coastguard Worker  br label %for.end13
98*9880d681SAndroid Build Coastguard Worker
99*9880d681SAndroid Build Coastguard Workerfor.end13:                                        ; preds = %for.end13.loopexit, %entry
100*9880d681SAndroid Build Coastguard Worker  ret i32 0
101*9880d681SAndroid Build Coastguard Worker}
102*9880d681SAndroid Build Coastguard Worker
103*9880d681SAndroid Build Coastguard Worker!0 = distinct !{!0, !1}
104*9880d681SAndroid Build Coastguard Worker!1 = !{!"llvm.loop.licm_versioning.disable"}
105