*** IR Dump After Loop-Closed SSA Form Pass *** ; Function Attrs: norecurse nounwind uwtable define dso_local void @_Z3fooP5info1P5info2Phi(%struct.info1* nocapture readonly %in, %struct.info2* nocapture %out, i8* nocapture readonly %p, i32 %N) local_unnamed_addr #0 { entry: %C = getelementptr inbounds %struct.info1, %struct.info1* %in, i64 0, i32 0 br label %for.body for.cond.cleanup: ; preds = %for.body ret void for.body: ; preds = %entry, %for.body %x.028 = phi i32 [ 1, %entry ], [ %add, %for.body ] %add = add nuw nsw i32 %x.028, 1 %0 = load i32, i32* %C, align 4, !tbaa !2 %mul = mul nsw i32 %0, %add %idx.ext = sext i32 %mul to i64 %add.ptr = getelementptr inbounds i8, i8* %p, i64 %idx.ext %1 = load i8, i8* %add.ptr, align 1, !tbaa !7 %conv = zext i8 %1 to i32 %sub = add nsw i32 %x.028, -1 %mul2 = mul nsw i32 %0, %sub %idx.ext3 = sext i32 %mul2 to i64 %add.ptr4 = getelementptr inbounds i8, i8* %p, i64 %idx.ext3 %2 = load i8, i8* %add.ptr4, align 1, !tbaa !7 %conv5 = zext i8 %2 to i32 %sub6 = add nsw i32 %x.028, -2 %mul8 = mul nsw i32 %0, %sub6 %idx.ext9 = sext i32 %mul8 to i64 %add.ptr10 = getelementptr inbounds i8, i8* %p, i64 %idx.ext9 %3 = load i8, i8* %add.ptr10, align 1, !tbaa !7 %conv11 = zext i8 %3 to i32 %sub12 = sub nsw i32 %conv, %conv5 %add13 = add nsw i32 %sub12, %conv11 %add14 = add nsw i32 %x.028, %N %idxprom = sext i32 %add14 to i64 %data = getelementptr inbounds %struct.info2, %struct.info2* %out, i64 %idxprom, i32 0 store i32 %add13, i32* %data, align 4, !tbaa !8 %cmp = icmp ult i32 %x.028, 99 br i1 %cmp, label %for.body, label %for.cond.cleanup } Wide IV: %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ] Cloning arithmetic IVUser: %add14 = add nsw i32 %x.028, %N INDVARS: eliminating %idxprom = sext i32 %add14 to i64 replaced by %5 = add nsw i64 %indvars.iv, %0 Cloning arithmetic IVUser: %sub6 = add nsw i32 %x.028, -2 INDVARS: Truncate IV %4 = add nsw i64 %indvars.iv, -2 for user %mul8 = mul nsw i32 %1, %sub6 Cloning arithmetic IVUser: %sub = add nsw i32 %x.028, -1 INDVARS: Truncate IV %3 = add nsw i64 %indvars.iv, -1 for user %mul2 = mul nsw i32 %1, %sub INDVARS: Truncate IV %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 for user %mul = mul nsw i32 %1, %add INDVARS: Rewriting loop exit condition to: LHS: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 op: != RHS: i32 100 IVCount: 99 Widen RHS: i64 100 *** IR Dump After Induction Variable Simplification *** ; Preheader: entry: %C = getelementptr inbounds %struct.info1, %struct.info1* %in, i64 0, i32 0 %0 = sext i32 %N to i64 br label %for.body ; Loop: for.body: ; preds = %entry, %for.body %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ] %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 %1 = load i32, i32* %C, align 4, !tbaa !2 %2 = trunc i64 %indvars.iv.next to i32 %mul = mul nsw i32 %1, %2 %idx.ext = sext i32 %mul to i64 %add.ptr = getelementptr inbounds i8, i8* %p, i64 %idx.ext %3 = load i8, i8* %add.ptr, align 1, !tbaa !7 %conv = zext i8 %3 to i32 %4 = add nsw i64 %indvars.iv, -1 %5 = trunc i64 %4 to i32 %mul2 = mul nsw i32 %1, %5 %idx.ext3 = sext i32 %mul2 to i64 %add.ptr4 = getelementptr inbounds i8, i8* %p, i64 %idx.ext3 %6 = load i8, i8* %add.ptr4, align 1, !tbaa !7 %conv5 = zext i8 %6 to i32 %7 = add nsw i64 %indvars.iv, -2 %8 = trunc i64 %7 to i32 %mul8 = mul nsw i32 %1, %8 %idx.ext9 = sext i32 %mul8 to i64 %add.ptr10 = getelementptr inbounds i8, i8* %p, i64 %idx.ext9 %9 = load i8, i8* %add.ptr10, align 1, !tbaa !7 %conv11 = zext i8 %9 to i32 %sub12 = sub nsw i32 %conv, %conv5 %add13 = add nsw i32 %sub12, %conv11 %10 = add nsw i64 %indvars.iv, %0 %data = getelementptr inbounds %struct.info2, %struct.info2* %out, i64 %10, i32 0 store i32 %add13, i32* %data, align 4, !tbaa !8 %exitcond = icmp ne i64 %indvars.iv.next, 100 br i1 %exitcond, label %for.body, label %for.cond.cleanup ; Exit blocks for.cond.cleanup: ; preds = %for.body ret void loop-idiom Scanning: F[_Z3fooP5info1P5info2Phi] Loop %for.body