Skip to content

Reorder scheduling order of MBBs#993

Merged
martien-de-jong merged 3 commits into
aie-publicfrom
stuckmann.interblock.sched.order
May 12, 2026
Merged

Reorder scheduling order of MBBs#993
martien-de-jong merged 3 commits into
aie-publicfrom
stuckmann.interblock.sched.order

Conversation

@F-Stuckmann

Copy link
Copy Markdown
Collaborator

Provide accurate scoreboard information for epilogues by scheduling its' prologues beforehand.

Awaiting QoR.

; loop: inner loop %for.body55.i82 and outer loop body %for.body.i68.
;
; RUN: llc -mtriple=aie2ps -verify-machineinstrs < %s | FileCheck %s

@martien-de-jong martien-de-jong May 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to aie2ps?

};

// Phase 1: (single-block) loops first, so they aren't constrained by
// their epilogues.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Loops will not be constrained anyway. The real reason is that the loop schedule should be taken into account by prologue epiloguie.

// post-order. post_order(E) ends with E itself, so E is scheduled AFTER
// everything reachable from it (its successors are already done -> precise
// inter-block latency for E) and BEFORE its non-loop predecessors. The
// latter is what keeps MaxLatencyFinder in precise mode for SWP prologues

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think prologues are irrelevant, except that it is frequently a successor of the epilogue. The goal is to bring the epilogue in precise mode.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have this feeling as well.

This could be:

  • insert loops
  • insert non-epilogues
  • insert epilogues.

We could also insert all blocks and reorder them with a custom comparison function Loop < Non-epilogue < Epilogue

for (auto &[MBB, BS] : Blocks) {
if (BS.Kind == BlockType::Loop) {
MBBSequence.push_back(MBB);
Push(MBB);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We push loop in pointer order, which is not deterministic. It's not performance critical to run over MF->Blocks and do the lookup for the blockstate.

;
; RUN: llc -mtriple=aie2ps -verify-machineinstrs < %s | FileCheck %s

source_filename = "Work/aie/0_0/src/0_0.cc"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this metadata,

target triple = "aie2ps-none-unknown-elf"
$_Z6conv2dILh1EL5act_t0EaaaLb0ELb1EEvPT1_PT2_PT3_R13conv2d_paramsS6_S6_ = comdat any

; Function Attrs: mustprogress

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename the function.

!18 = !{!8, !10, i64 84}
!19 = !{!8, !10, i64 120}
!20 = !{!21}
!21 = distinct !{!21, !22, !"_Z18conv2d_generic_optILh1EL5act_t0EL10out_mode_t0EaaaEvPiS2_S2_S2_S2_R13conv2d_params: %input"}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename this. See end-to-end tests.

; CHECK-NEXT: padda [p1], m0; movs dn4, r27; mov m5, r19 // Delay Slot 4
; CHECK-NEXT: vlda.ups.2x cml0, s0, upssign1, [p1, #0]; movs dc4, r5; mov m0, r21 // Delay Slot 3
; CHECK-NEXT: padda [p1], m7; paddb.3d [p0], d0; padds [p6], m5 // Delay Slot 2
; CHECK-NEXT: vlda.ups.2x cmh0, s0, upssign1, [p1, #0]; paddb.3d [p6], d1; movx srssign0, #0; mov r5, dc4 // Delay Slot 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is flying high :-)

@andcarminati

Copy link
Copy Markdown
Collaborator

This looks good! Some nits and suggestions!

@F-Stuckmann F-Stuckmann force-pushed the stuckmann.interblock.sched.order branch 3 times, most recently from d94d0e7 to 789b8c6 Compare May 11, 2026 14:26
@martien-de-jong martien-de-jong merged commit b9f4796 into aie-public May 12, 2026
7 checks passed
@martien-de-jong martien-de-jong deleted the stuckmann.interblock.sched.order branch May 12, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants