summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/RegisterCoalescer.cpp
diff options
context:
space:
mode:
authorKRM7 <Krisztian.Rugasi@hightec-rt.com>2025-08-05 15:32:31 +0200
committerGitHub <noreply@github.com>2025-08-05 22:32:31 +0900
commitee47427386eb405d347bb2d24c925c3130bdde53 (patch)
treed9fca37a992450e9f32f4225dde1e0be67f1f9fd /llvm/lib/CodeGen/RegisterCoalescer.cpp
parentfd07d90f9f95190cb3abb901ae3d98eb67b84573 (diff)
[RegisterCoalescer] Fix subrange update when rematerialization widens a def (#151974)
Currently, when an instruction rematerialized by the register coalescer defines more subregs of the destination register than the original COPY instruction did, we only add dead defs for the newly defined subregs if they were not defined anywhere else. For example, consider something like this before rematerialization: ``` %0:reg64 = CONSTANT 1 %1:reg128.sub_lo64_lo32 = COPY %0.lo32 %1:reg128.sub_lo64_hi32 = ... ... ``` that would look like this after rematerializing `%0`: ``` %0:reg64 = CONSTANT 2 %1:reg128.sub_lo64 = CONSTANT 2 %1:reg128.sub_lo64_hi32 = ... ... ``` A dead def would not be added for `%1.sub_lo64_hi32` at the 2nd instruction because it's subrange wasn't empty beforehand.
Diffstat (limited to 'llvm/lib/CodeGen/RegisterCoalescer.cpp')
-rw-r--r--llvm/lib/CodeGen/RegisterCoalescer.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index 2d7987a2e198..514f2f02d642 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -1624,11 +1624,11 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
UpdatedSubRanges = true;
} else {
// We know that this lane is defined by this instruction,
- // but at this point it may be empty because it is not used by
- // anything. This happens when updateRegDefUses adds the missing
- // lanes. Assign that lane a dead def so that the interferences
- // are properly modeled.
- if (SR.empty())
+ // but at this point it might not be live because it was not defined
+ // by the original instruction. This happens when the
+ // rematerialization widens the defined register. Assign that lane a
+ // dead def so that the interferences are properly modeled.
+ if (!SR.liveAt(DefIndex))
SR.createDeadDef(DefIndex, Alloc);
}
}