Skip to content

[AutoBump] Merge with fixes of 58a88001 (Feb 05) (28)#930

Open
jorickert wants to merge 2 commits intoaie-publicfrom
bump_to_58a88001
Open

[AutoBump] Merge with fixes of 58a88001 (Feb 05) (28)#930
jorickert wants to merge 2 commits intoaie-publicfrom
bump_to_58a88001

Conversation

@jorickert
Copy link
Copy Markdown
Contributor

@jorickert jorickert commented Apr 10, 2026

Needs downstream changes

arsenm and others added 2 commits February 5, 2025 23:29
This fixes the handling of subregister extract copies. This
will allow AMDGPU to remove its implementation of
shouldRewriteCopySrc, which exists as a 10 year old workaround
to this bug. peephole-opt-fold-reg-sequence-subreg.mir will
show the expected improvement once the custom implementation
is removed.

The copy coalescing processing here is overly abstracted
from what's actually happening. Previously when visiting
coalescable copy-like instructions, we would parse the
sources one at a time and then pass the def of the root
instruction into findNextSource. This means that the
first thing the new ValueTracker constructed would do
is getVRegDef to find the instruction we are currently
processing. This adds an unnecessary step, placing
a useless entry in the RewriteMap, and required skipping
the no-op case where getNewSource would return the original
source operand. This was a problem since in the case
of a subregister extract, shouldRewriteCopySource would always
say that it is useful to rewrite and the use-def chain walk
would abort, returning the original operand. Move the process
to start looking at the source operand to begin with.

This does not fix the confused handling in the uncoalescable
copy case which is proving to be more difficult. Some currently
handled cases have multiple defs from a single source, and other
handled cases have 0 input operands. It would be simpler if
this was implemented with isCopyLikeInstr, rather than guessing
at the operand structure as it does now.

There are some improvements and some regressions. The
regressions appear to be downstream issues for the most part. One
of the uglier regressions is in PPC, where a sequence of insert_subrgs
is used to build registers. I opened #125502 to use reg_sequence instead,
which may help.

The worst regression is an absurd SPARC testcase using a <251 x fp128>,
which uses a very long chain of insert_subregs.

We need improved subregister handling locally in PeepholeOptimizer,
and other pasess like MachineCSE to fix some of the other regressions.
We should handle subregister composes and folding more indexes
into insert_subreg and reg_sequence.
@jorickert jorickert marked this pull request as ready for review April 10, 2026 13:38
Base automatically changed from bump_to_92e3cd70 to bump_to_44f638f8 April 15, 2026 16:27
Base automatically changed from bump_to_44f638f8 to aie-public April 15, 2026 19:22
@jorickert jorickert closed this Apr 16, 2026
@jorickert jorickert reopened this Apr 16, 2026
@jorickert jorickert enabled auto-merge April 16, 2026 06:48
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.

2 participants