<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/CodeGen/LiveRangeEdit.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>CodeGen: Remove TRI argument from reMaterialize (#158229)</title>
<updated>2025-11-11T00:23:36+00:00</updated>
<author>
<name>Matt Arsenault</name>
<email>Matthew.Arsenault@amd.com</email>
</author>
<published>2025-11-11T00:23:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a88fa64e2570bac79545e24c010bf2fdc21162cf'/>
<id>a88fa64e2570bac79545e24c010bf2fdc21162cf</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[LRE] Adjust order of cases in eliminateDeadDefs (#162108)</title>
<updated>2025-10-07T14:21:32+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-10-07T14:21:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=459472eef056ba5119a5da37a5cbb789fac531ae'/>
<id>459472eef056ba5119a5da37a5cbb789fac531ae</id>
<content type='text'>
If we have a rematerializable instruction without live virtual register
uses (that we didn't heuristically decide to shrink), but with a physreg
use, we were creating a kill to keep the physreg operand liveness
unchanged. This meant we *weren't* keeping around the remat instruction,
and thus inhibiting future remat within the original live interval. If
we keep the remat instruction, that *also* keeps the physreg use, and
thus we can achieve both objectives at once.

Noticed this via inspection, and we don't currently seem to have any
rematerializable instructions which could observe the difference. This
could in theory happen for both trivial and non-trivial remat, but
requires the rematerialization of an instruction with a physreg use.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we have a rematerializable instruction without live virtual register
uses (that we didn't heuristically decide to shrink), but with a physreg
use, we were creating a kill to keep the physreg operand liveness
unchanged. This meant we *weren't* keeping around the remat instruction,
and thus inhibiting future remat within the original live interval. If
we keep the remat instruction, that *also* keeps the physreg use, and
thus we can achieve both objectives at once.

Noticed this via inspection, and we don't currently seem to have any
rematerializable instructions which could observe the difference. This
could in theory happen for both trivial and non-trivial remat, but
requires the rematerialization of an instruction with a physreg use.</pre>
</div>
</content>
</entry>
<entry>
<title>[CodeGen] Finish untangling LRE::scanRemattable [nfc] (#161963)</title>
<updated>2025-10-07T14:19:58+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-10-07T14:19:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6ae658308919e1c01cb4221f8cd07365c7ce6fc2'/>
<id>6ae658308919e1c01cb4221f8cd07365c7ce6fc2</id>
<content type='text'>
This is an attempt to simplify the rematerialization logic in
InlineSpiller and SplitKit. I'd earlier done the same for
RegisterCoalescer in 57b673.

The basic idea of this change is that we don't need to check whether an
instruction is rematerializable early. Instead, we can defer the check
to the point where we're actually trying to materialize something. We
also don't need to indirect that query through a VNI key, and can
instead just check the instruction directly at the use site.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is an attempt to simplify the rematerialization logic in
InlineSpiller and SplitKit. I'd earlier done the same for
RegisterCoalescer in 57b673.

The basic idea of this change is that we don't need to check whether an
instruction is rematerializable early. Instead, we can defer the check
to the point where we're actually trying to materialize something. We
also don't need to indirect that query through a VNI key, and can
instead just check the instruction directly at the use site.</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[RegAlloc] Strengthen asserts in LiveRangeEdit::scanRemattable [nfc]" (#160897)</title>
<updated>2025-09-26T14:55:59+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-09-26T14:55:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9412769c1e03a928ba83ee24da084e26ca713dbf'/>
<id>9412769c1e03a928ba83ee24da084e26ca713dbf</id>
<content type='text'>
Reverts llvm/llvm-project#160765. Failures on buildbot indicate second
assertion does not in fact hold.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverts llvm/llvm-project#160765. Failures on buildbot indicate second
assertion does not in fact hold.</pre>
</div>
</content>
</entry>
<entry>
<title>[RegAlloc] Strengthen asserts in LiveRangeEdit::scanRemattable [nfc] (#160765)</title>
<updated>2025-09-26T13:55:07+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-09-26T13:55:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bba91727789bed302758dac282107a44c7b33504'/>
<id>bba91727789bed302758dac282107a44c7b33504</id>
<content type='text'>
We should always be able to find the VNInfo in the original live
interval which corresponds to the subset we're trying to spill, and the
only cases where we have a VNInfo without a definition instruction are
if the vni is unused, or corresponds to a phi. Adjust the code structure
to explicitly check for PHIDef, and assert the stronger conditions.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We should always be able to find the VNInfo in the original live
interval which corresponds to the subset we're trying to spill, and the
only cases where we have a VNInfo without a definition instruction are
if the vni is unused, or corresponds to a phi. Adjust the code structure
to explicitly check for PHIDef, and assert the stronger conditions.</pre>
</div>
</content>
</entry>
<entry>
<title>[RegAlloc] Account for use availability when applying rematerializable weight discount (#159180)</title>
<updated>2025-09-25T23:57:12+00:00</updated>
<author>
<name>Luke Lau</name>
<email>luke@igalia.com</email>
</author>
<published>2025-09-25T23:57:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=be23cdc858b860fbcc17c1f260d8a127a24d90b6'/>
<id>be23cdc858b860fbcc17c1f260d8a127a24d90b6</id>
<content type='text'>
This aims to fix the issue that caused https://reviews.llvm.org/D106408
to be reverted.

CalcSpillWeights will reduce the weight of an interval by half if it's
considered rematerializable, so it will be evicted before others.

It does this by checking TII.isTriviallyReMaterializable. However
rematerialization may still fail if any of the defining MI's uses aren't
available at the locations it needs to be rematerialized.
LiveRangeEdit::canRematerializeAt calls allUsesAvailableAt to check this
but CalcSpillWeights doesn't, so the two diverge.

This fixes it by also checking allUsesAvailableAt in CalcSpillWeights. 

In practice this has zero change AArch64/X86-64/RISC-V as measured on
llvm-test-suite, but prevents weights from being perturbed in an
upcoming patch which enables more rematerialization by re-attempting
https://reviews.llvm.org/D106408</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This aims to fix the issue that caused https://reviews.llvm.org/D106408
to be reverted.

CalcSpillWeights will reduce the weight of an interval by half if it's
considered rematerializable, so it will be evicted before others.

It does this by checking TII.isTriviallyReMaterializable. However
rematerialization may still fail if any of the defining MI's uses aren't
available at the locations it needs to be rematerialized.
LiveRangeEdit::canRematerializeAt calls allUsesAvailableAt to check this
but CalcSpillWeights doesn't, so the two diverge.

This fixes it by also checking allUsesAvailableAt in CalcSpillWeights. 

In practice this has zero change AArch64/X86-64/RISC-V as measured on
llvm-test-suite, but prevents weights from being perturbed in an
upcoming patch which enables more rematerialization by re-attempting
https://reviews.llvm.org/D106408</pre>
</div>
</content>
</entry>
<entry>
<title>[TII] Split isTrivialReMaterializable into two versions [nfc] (#160377)</title>
<updated>2025-09-25T01:52:17+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-09-25T01:52:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ea721e2fa1cd2a35652082dae1d0987de531883d'/>
<id>ea721e2fa1cd2a35652082dae1d0987de531883d</id>
<content type='text'>
This change builds on https://github.com/llvm/llvm-project/pull/160319
which tries to clarify which *callers* (not backends) assume that the
result is actually trivial.

This change itself should be NFC. Essentially, I'm just renaming the
existing isTrivialRematerializable to the non-trivial version and then
adding a new trivial version (with the same name as the prior function)
and simplifying a few callers which want that semantic.

This change does *not* enable non-trivial remat any more broadly than
was already done for our targets which were lying through the old APIs;
that will come separately. The goal here is simply to make the code
easier to follow in terms of what assumptions are being made where.

---------

Co-authored-by: Luke Lau &lt;luke_lau@icloud.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change builds on https://github.com/llvm/llvm-project/pull/160319
which tries to clarify which *callers* (not backends) assume that the
result is actually trivial.

This change itself should be NFC. Essentially, I'm just renaming the
existing isTrivialRematerializable to the non-trivial version and then
adding a new trivial version (with the same name as the prior function)
and simplifying a few callers which want that semantic.

This change does *not* enable non-trivial remat any more broadly than
was already done for our targets which were lying through the old APIs;
that will come separately. The goal here is simply to make the code
easier to follow in terms of what assumptions are being made where.

---------

Co-authored-by: Luke Lau &lt;luke_lau@icloud.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[CodeGen] Untangle RegisterCoalescer from LRE's ScannedRemattable flag [nfc[ (#159839)</title>
<updated>2025-09-20T01:28:26+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-09-20T01:28:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=57b673b3c15e5c606896a6b39b41a6a2867547ec'/>
<id>57b673b3c15e5c606896a6b39b41a6a2867547ec</id>
<content type='text'>
LiveRangeEdit's rematerialization checking logic is used in two quite
different ways. For SplitKit and InlineSpiller, we're analyzing all defs
associated with a live interval, doing that analysis up front, and then
using the result a bit later. The RegisterCoalescer, we're analysing
exactly one ValNo at a time, and using the legality result immediately.
LRE had a checkRematerializable which existed basically to adapt the
later into the former usage model.

Instead, this change bypasses the ScannedRemat and Remattable
structures, and directly queries the underlying routines. This is easy
to read, and makes it more clear as to which uses actually need the
deferred analysis. (A following change may try to unwind that too, but
it's not strictly NFC.)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LiveRangeEdit's rematerialization checking logic is used in two quite
different ways. For SplitKit and InlineSpiller, we're analyzing all defs
associated with a live interval, doing that analysis up front, and then
using the result a bit later. The RegisterCoalescer, we're analysing
exactly one ValNo at a time, and using the legality result immediately.
LRE had a checkRematerializable which existed basically to adapt the
later into the former usage model.

Instead, this change bypasses the ScannedRemat and Remattable
structures, and directly queries the underlying routines. This is easy
to read, and makes it more clear as to which uses actually need the
deferred analysis. (A following change may try to unwind that too, but
it's not strictly NFC.)</pre>
</div>
</content>
</entry>
<entry>
<title>[RegAlloc] Fix register's live range for early-clobber (#152895)</title>
<updated>2025-08-20T01:02:59+00:00</updated>
<author>
<name>Luo, Yuanke</name>
<email>lyk_03@hotmail.com</email>
</author>
<published>2025-08-20T01:02:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ba6bb6929e7eb934f86adb1a942d2d274d18b1dd'/>
<id>ba6bb6929e7eb934f86adb1a942d2d274d18b1dd</id>
<content type='text'>
When rematerialize a virtual register the register may be early
clobbered.
However rematerializeAt(...) just return the slot index of Slot_Register
which cause mis-calculating live range for the register

---------

Co-authored-by: Yuanke Luo &lt;ykluo@birentech.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When rematerialize a virtual register the register may be early
clobbered.
However rematerializeAt(...) just return the slot index of Slot_Register
which cause mis-calculating live range for the register

---------

Co-authored-by: Yuanke Luo &lt;ykluo@birentech.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[CodeGen] Remove parameter from LiveRangeEdit::canRematerializeAt [NFC]</title>
<updated>2025-03-14T16:12:07+00:00</updated>
<author>
<name>Philip Reames</name>
<email>preames@rivosinc.com</email>
</author>
<published>2025-03-14T16:04:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bdb4012fe3f9e30e2ea3e1d92524ad7725b2957e'/>
<id>bdb4012fe3f9e30e2ea3e1d92524ad7725b2957e</id>
<content type='text'>
Only one caller cares about the true case of this parameter, so move
the check to that single caller.  Note that RegisterCoalescer seems
like it should care, but it already duplicates the check several
lines above.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Only one caller cares about the true case of this parameter, so move
the check to that single caller.  Note that RegisterCoalescer seems
like it should care, but it already duplicates the check several
lines above.
</pre>
</div>
</content>
</entry>
</feed>
