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