Avoid reusing a register during constant loading (#5379)

Avoid reusing a register when loading a constant, allocating a temporary instead.
This commit is contained in:
Trevor Elliott
2022-12-05 18:37:53 -08:00
committed by GitHub
parent 4933762d81
commit 353a681671
3 changed files with 46 additions and 41 deletions

View File

@@ -235,7 +235,7 @@ impl Inst {
alloc_tmp: &mut F,
) -> SmallInstVec<Inst> {
let insts = Inst::load_const_imm(rd, value, alloc_tmp);
insts.unwrap_or(LoadConstant::U32(value as u32).load_constant(rd))
insts.unwrap_or(LoadConstant::U32(value as u32).load_constant(rd, alloc_tmp))
}
pub fn load_constant_u64<F: FnMut(Type) -> Writable<Reg>>(
@@ -244,7 +244,7 @@ impl Inst {
alloc_tmp: &mut F,
) -> SmallInstVec<Inst> {
let insts = Inst::load_const_imm(rd, value, alloc_tmp);
insts.unwrap_or(LoadConstant::U64(value).load_constant(rd))
insts.unwrap_or(LoadConstant::U64(value).load_constant(rd, alloc_tmp))
}
pub(crate) fn construct_auipc_and_jalr(