Files
Michael Berg efa99eccfc [LoopDist] Add metadata for checking post process state of distribute… (#153902)
…d loops

Add a count of the number of partitions LoopDist made when distributing
a loop in meta data, then check for loops which are already distributed
to prevent reprocessing.

We see this happen on some spec apps, LD is on by default at SiFive.
2025-08-22 11:05:31 -07:00

131 lines
6.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -aa-pipeline=basic-aa -passes=loop-distribute -enable-loop-distribute -verify-loop-info -verify-dom-info -debug-only=loop-distribute --disable-output -S < %s 2>&1 | FileCheck %s
; REQUIRES: asserts
; Test if a loop already distributed will not reprocess because of metadata
; information marking it as processed.
; CHECK: LDist: Distributed loop guarded for reprocessing
; CHECK: LDist: Skipping;
define dso_local void @_Z13distribution3PiS_S_S_i(ptr noundef captures(none) %a, ptr noundef readonly captures(none) %b, ptr noundef captures(none) %c, ptr noundef writeonly captures(none) %d, i64 noundef signext %len) {
entry:
%cmp = icmp sgt i64 %len, 0
br i1 %cmp, label %end, label %for.body.lver.check
for.body.lver.check: ; preds = %entry
%0 = shl i64 %len, 2
%scevgep = getelementptr i8, ptr %a, i64 %0
%scevgep1 = getelementptr i8, ptr %c, i64 -4
%scevgep2 = getelementptr i8, ptr %c, i64 %0
%scevgep3 = getelementptr i8, ptr %d, i64 %0
%scevgep4 = getelementptr i8, ptr %b, i64 %0
%bound0 = icmp ult ptr %a, %scevgep2
%bound1 = icmp ult ptr %scevgep1, %scevgep
%found.conflict = and i1 %bound0, %bound1
%bound05 = icmp ult ptr %a, %scevgep3
%bound16 = icmp ult ptr %d, %scevgep
%found.conflict7 = and i1 %bound05, %bound16
%conflict.rdx = or i1 %found.conflict, %found.conflict7
%bound08 = icmp ult ptr %a, %scevgep4
%bound19 = icmp ult ptr %b, %scevgep
%found.conflict10 = and i1 %bound08, %bound19
%conflict.rdx11 = or i1 %conflict.rdx, %found.conflict10
%bound012 = icmp ult ptr %scevgep1, %scevgep3
%bound113 = icmp ult ptr %d, %scevgep2
%found.conflict14 = and i1 %bound012, %bound113
%conflict.rdx15 = or i1 %conflict.rdx11, %found.conflict14
%bound016 = icmp ult ptr %d, %scevgep4
%bound117 = icmp ult ptr %b, %scevgep3
%found.conflict18 = and i1 %bound016, %bound117
%conflict.rdx19 = or i1 %conflict.rdx15, %found.conflict18
br i1 %conflict.rdx19, label %for.body.ph.lver.orig, label %for.body.ph.ldist1
for.body.ph.lver.orig: ; preds = %for.body.lver.check
br label %for.body.lver.orig
for.body.lver.orig: ; preds = %for.body.lver.orig, %for.body.ph.lver.orig
%indvars.iv.lver.orig = phi i64 [ 0, %for.body.ph.lver.orig ], [ %indvars.iv.next.lver.orig, %for.body.lver.orig ]
%arrayidx.lver.orig = getelementptr inbounds i32, ptr %b, i64 %indvars.iv.lver.orig
%i2.lver.orig = load i32, ptr %arrayidx.lver.orig, align 4, !tbaa !0
%add4.lver.orig = add nsw i32 %i2.lver.orig, 1
%arrayidx8.lver.orig = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.lver.orig
store i32 %add4.lver.orig, ptr %arrayidx8.lver.orig, align 4, !tbaa !0
%i3.lver.orig = getelementptr i32, ptr %c, i64 %indvars.iv.lver.orig
%arrayidx17.lver.orig = getelementptr i8, ptr %i3.lver.orig, i64 -4
%i4.lver.orig = load i32, ptr %arrayidx17.lver.orig, align 4, !tbaa !0
%sub18.lver.orig = sub nsw i32 %add4.lver.orig, %i4.lver.orig
store i32 %sub18.lver.orig, ptr %i3.lver.orig, align 4, !tbaa !0
%i5.lver.orig = load i32, ptr %arrayidx8.lver.orig, align 4, !tbaa !0
%add27.lver.orig = add nsw i32 %i5.lver.orig, 2
%arrayidx31.lver.orig = getelementptr inbounds i32, ptr %d, i64 %indvars.iv.lver.orig
store i32 %add27.lver.orig, ptr %arrayidx31.lver.orig, align 4, !tbaa !0
%indvars.iv.next.lver.orig = add i64 %indvars.iv.lver.orig, 1
%cmp1.not.lver.orig = icmp eq i64 %indvars.iv.next.lver.orig, %len
br i1 %cmp1.not.lver.orig, label %end.loopexit.loopexit, label %for.body.lver.orig, !llvm.loop !4
for.body.ph.ldist1: ; preds = %for.body.lver.check
br label %for.body.ldist1
for.body.ldist1: ; preds = %for.body.ldist1, %for.body.ph.ldist1
%indvars.iv.ldist1 = phi i64 [ 0, %for.body.ph.ldist1 ], [ %indvars.iv.next.ldist1, %for.body.ldist1 ]
%arrayidx.ldist1 = getelementptr inbounds i32, ptr %b, i64 %indvars.iv.ldist1
%i2.ldist1 = load i32, ptr %arrayidx.ldist1, align 4, !tbaa !0, !alias.scope !7
%add4.ldist1 = add nsw i32 %i2.ldist1, 1
%arrayidx8.ldist1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.ldist1
store i32 %add4.ldist1, ptr %arrayidx8.ldist1, align 4, !tbaa !0, !alias.scope !10, !noalias !12
%i3.ldist1 = getelementptr i32, ptr %c, i64 %indvars.iv.ldist1
%arrayidx17.ldist1 = getelementptr i8, ptr %i3.ldist1, i64 -4
%i4.ldist1 = load i32, ptr %arrayidx17.ldist1, align 4, !tbaa !0, !alias.scope !15, !noalias !16
%sub18.ldist1 = sub nsw i32 %add4.ldist1, %i4.ldist1
store i32 %sub18.ldist1, ptr %i3.ldist1, align 4, !tbaa !0, !alias.scope !15, !noalias !16
%indvars.iv.next.ldist1 = add i64 %indvars.iv.ldist1, 1
%cmp1.not.ldist1 = icmp eq i64 %indvars.iv.next.ldist1, %len
br i1 %cmp1.not.ldist1, label %for.body.ph, label %for.body.ldist1, !llvm.loop !17
for.body.ph: ; preds = %for.body.ldist1
br label %for.body
for.body: ; preds = %for.body, %for.body.ph
%indvars.iv = phi i64 [ 0, %for.body.ph ], [ %indvars.iv.next, %for.body ]
%arrayidx8 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
%i5 = load i32, ptr %arrayidx8, align 4, !tbaa !0, !alias.scope !10, !noalias !12
%add27 = add nsw i32 %i5, 2
%arrayidx31 = getelementptr inbounds i32, ptr %d, i64 %indvars.iv
store i32 %add27, ptr %arrayidx31, align 4, !tbaa !0, !alias.scope !16, !noalias !7
%indvars.iv.next = add i64 %indvars.iv, 1
%cmp1.not = icmp eq i64 %indvars.iv.next, %len
br i1 %cmp1.not, label %end.loopexit.loopexit20, label %for.body, !llvm.loop !17
end.loopexit.loopexit: ; preds = %for.body.lver.orig
br label %end.loopexit
end.loopexit.loopexit20: ; preds = %for.body
br label %end.loopexit
end.loopexit: ; preds = %end.loopexit.loopexit20, %end.loopexit.loopexit
br label %end
end: ; preds = %end.loopexit, %entry
ret void
}
!0 = !{!1, !1, i64 0}
!1 = !{!"int", !2, i64 0}
!2 = !{!"omnipotent char", !3, i64 0}
!3 = !{!"Simple C++ TBAA"}
!4 = distinct !{!4, !5, !6}
!5 = !{!"llvm.loop.mustprogress"}
!6 = !{!"llvm.loop.isdistributed", i32 1}
!7 = !{!8}
!8 = distinct !{!8, !9}
!9 = distinct !{!9, !"LVerDomain"}
!10 = !{!11}
!11 = distinct !{!11, !9}
!12 = !{!13, !14, !8}
!13 = distinct !{!13, !9}
!14 = distinct !{!14, !9}
!15 = !{!13}
!16 = !{!14}
!17 = distinct !{!17, !5}