Skip to content

[AIEX] Fix register rewriting failed: cycle in copy bundle#793

Merged
F-Stuckmann merged 2 commits intoaie-publicfrom
andreu.fix.extra.bundle
Mar 12, 2026
Merged

[AIEX] Fix register rewriting failed: cycle in copy bundle#793
F-Stuckmann merged 2 commits intoaie-publicfrom
andreu.fix.extra.bundle

Conversation

@andcarminati
Copy link
Copy Markdown
Collaborator

To fix the problem, we introduce infrastructure to distinguish between expandable and rewritable registers in the AIEUnallocatedSuperRegRewriter pass.

Key changes:

- Add `isExpandableRegister()` helper to check if a register has
a subregister split, consolidating duplicate checks

- Replace `RegRewriteInfo` typedef with a struct containing two lists:

  - `ExpandableRegs`: All registers with SubRegSplit (superset)
  - `RewritableRegs`: Subset that can be immediately rewritten

- Rename `getRewriteCandidates()` to `getRewriteAndExpandCandidates()`
to reflect the dual-list approach

- Update `expandCopyBundles()` to process all expandable registers

- Update `rewriteCandidates()` to process only rewritable registers

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: superreg (double r)

LLVM_DEBUG(dbgs() << "Expandable (not rewritable) "
<< printReg(Reg, &TRI, 0, &MRI) << ":"
<< printRegClassOrBank(Reg, MRI, &TRI) << '\n');
Info.ExpandableRegs.push_back({Reg, AllSubRegs});
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.

Why don't we just store a pointer to SubRegSplit? That's a const pointer. Now we create three copies, one to populate it, one to create the pair, and one to push it into the vector.

if (Reg.isPhysical())
return false;

auto &SubRegSplit = TRI.getSubRegSplit(MRI.getRegClass(Reg)->getID());
Copy link
Copy Markdown
Collaborator

@F-Stuckmann F-Stuckmann Mar 5, 2026

Choose a reason for hiding this comment

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

nit: we could return SubRegSplit as an optional

@F-Stuckmann F-Stuckmann force-pushed the andreu.fix.extra.bundle branch from 0ddfea2 to 337faf4 Compare March 11, 2026 11:02
@F-Stuckmann F-Stuckmann requested a review from abnikant as a code owner March 11, 2026 11:02
@F-Stuckmann F-Stuckmann enabled auto-merge (rebase) March 11, 2026 11:02
Related to the expansion of copy bundles whose reg candidates cannot be
rewritten.
Introduce infrastructure to distinguish between expandable and
rewritable registers in the AIEUnallocatedSuperRegRewriter pass.

Key changes:

- Add `isExpandableRegister()` helper to check if a register has
a subregister split, consolidating duplicate checks

- Replace `RegRewriteInfo` typedef with a struct containing two lists:

  - `ExpandableRegs`: All registers with SubRegSplit (superset)
  - `RewritableRegs`: Subset that can be immediately rewritten

- Rename `getRewriteCandidates()` to `getRewriteAndExpandCandidates()`
to reflect the dual-list approach

- Update `expandCopyBundles()` to process all expandable registers

- Update `rewriteCandidates()` to process only rewritable registers
@konstantinschwarz konstantinschwarz force-pushed the andreu.fix.extra.bundle branch from 337faf4 to 03dd0c0 Compare March 12, 2026 17:59
@F-Stuckmann F-Stuckmann merged commit b169186 into aie-public Mar 12, 2026
7 checks passed
@F-Stuckmann F-Stuckmann deleted the andreu.fix.extra.bundle branch March 12, 2026 19:40
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