Hi all,
For input IR:
; Function Attrs: argmemonly nofree norecurse nosync nounwind
define dso_local void @vec_mov(ptr noalias nocapture noundef readonly %s, ptr noalias nocapture noundef writeonly %d, i64 noundef %N) local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %for.body, %entry
%i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
%cmp = icmp ult i64 %i.0, %N
br i1 %cmp, label %for.body, label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.cond
ret void
for.body: ; preds = %for.cond
%arrayidx = getelementptr inbounds i32, ptr %s, i64 %i.0
%0 = load i32, ptr %arrayidx, align 4, !tbaa !6
%arrayidx1 = getelementptr inbounds i32, ptr %d, i64 %i.0
store i32 %0, ptr %arrayidx1, align 4, !tbaa !6
%inc = add nuw i64 %i.0, 1
br label %for.cond, !llvm.loop !10
}
I’m wondering whether there is a pass transform the input IR to this:
; Function Attrs: argmemonly nofree norecurse nosync nounwind
define dso_local void @vec_mov(ptr noalias nocapture noundef readonly %s, ptr noalias nocapture noundef writeonly %d, i64 noundef %N) local_unnamed_addr #0 {
entry:
br label %for.cond
for.cond: ; preds = %for.body, %entry
%i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
%s.start = getelementptr inbounds i32, ptr %s.offset, i64 0
%d.start = getelementptr inbounds i32, ptr %d.offset, i64 0
%s.offset = phi ptr [ %s.start, %entry ], [ %s.next, %entry ]
%d.offset = phi ptr [ %d.start, %entry ], [ %d.next, %entry ]
%cmp = icmp ult i64 %i.0, %N
br i1 %cmp, label %for.body, label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.cond
ret void
for.body: ; preds = %for.cond
%0 = load i32, ptr %s.offset, align 4, !tbaa !6
store i32 %0, ptr %d.offset, align 4, !tbaa !6
%s.next = getelementptr inbounds i32, ptr %s.offset, i64 1
%d.next = getelementptr inbounds i32, ptr %d.offset, i64 1
%inc = add nuw i64 %i.0, 1
br label %for.cond, !llvm.loop !10
}
I’m totally newbee in this area, but I feel it is something relative to SCEV. I skimmed passes in llvm/lib/Transforms/Scalar
folder but nothing similar is found to do such job.
So is there something can do this job already? If not, what is knowledge I need to dive in to make a new pass to do it.
Thank you in advance.