[llvm-branch-commits] [llvm] [CodeGen] Enhance createFrom for sub-reg aware cloning (PR #174999)
Christudasan Devadasan via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 12 02:16:42 PST 2026
================
@@ -52,8 +52,16 @@ LiveInterval &LiveRangeEdit::createEmptyIntervalFrom(Register OldReg,
return LI;
}
-Register LiveRangeEdit::createFrom(Register OldReg) {
+Register LiveRangeEdit::createFrom(Register OldReg,
+ const TargetRegisterClass *RC) {
Register VReg = MRI.cloneVirtualRegister(OldReg);
+
+ // If RC is given, set it now. This is needed for cloning a new VReg with a
+ // smaller RC from its original virtual register, mainly used for subreg
+ // reload. The cloning is done first to ensure the vreg flags are preserved.
+ if (RC)
+ MRI.setRegClass(VReg, RC);
----------------
cdevadas wrote:
You mean, a compatible subregister of the OldReg - the superclass?
https://github.com/llvm/llvm-project/pull/174999
More information about the llvm-branch-commits
mailing list