aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/RISCV
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 18:27:54 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 18:27:54 +0800
commitfc09d2213407d3b7cfcf306368aff9916e359a2d (patch)
tree84b9ba34d7af5c25cb675fde2165830d327c7321 /backend/lib/Target/RISCV
parentf7b25b15eaed953baa50dd2cb3e711a88a8927df (diff)
downloadrcc-project-fc09d2213407d3b7cfcf306368aff9916e359a2d.tar.gz
rcc-project-fc09d2213407d3b7cfcf306368aff9916e359a2d.tar.xz
[RISCV] Preserve live constants when folding extensions
Diffstat (limited to 'backend/lib/Target/RISCV')
-rw-r--r--backend/lib/Target/RISCV/RISCVCodeGen.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/backend/lib/Target/RISCV/RISCVCodeGen.cpp b/backend/lib/Target/RISCV/RISCVCodeGen.cpp
index 9cf7b53..bc437c0 100644
--- a/backend/lib/Target/RISCV/RISCVCodeGen.cpp
+++ b/backend/lib/Target/RISCV/RISCVCodeGen.cpp
@@ -127,7 +127,8 @@ extendIntegerImmediate(const IntegerImmediate &Value, std::uint32_t DestinationW
return makeUnexpected(ErrorCode::VerificationError,
"RISC-V constant extension requires virtual-register operands");
}
- const MachineOperand *SourceDefinition = Function.registerInfo().getUniqueVRegDef(*Source);
+ const Register SourceRegister = *Source;
+ const MachineOperand *SourceDefinition = Function.registerInfo().getUniqueVRegDef(SourceRegister);
const MachineInstr *SourceDef = SourceDefinition == nullptr ? nullptr : SourceDefinition->parent();
if (SourceDef == nullptr || SourceDef->opcode() != opcode(GenericOpcode::G_CONSTANT))
return makeUnexpected(ErrorCode::Unsupported,
@@ -161,7 +162,7 @@ extendIntegerImmediate(const IntegerImmediate &Value, std::uint32_t DestinationW
if (!Added)
return std::unexpected(Added.error());
- if (Function.registerInfo().useEmpty(*Source)) {
+ if (Function.registerInfo().useEmpty(SourceRegister)) {
MachineInstr *Def = const_cast<MachineInstr *>(SourceDef);
MachineBasicBlock *Parent = Def->parent();
if (Parent == nullptr)