mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
Merge #828
828: No need to emit add of constant zero. r=losfair a=nlewycky # Description While debugging singlepass generated code, I noticed unnecessary adds of zero. Removing them made the resulting assembly shorter and easier to analyze. Co-authored-by: Nick Lewycky <nick@wasmer.io> Co-authored-by: nlewycky <nick@wasmer.io> Co-authored-by: Heyang Zhou <zhy20000919@hotmail.com>
This commit is contained in:
commit
8a2052bb90
@ -1514,6 +1514,7 @@ impl X64FunctionCode {
|
||||
|
||||
// This branch is used for emitting "faster" code for the special case of (offset + value_size) not exceeding u32 range.
|
||||
match (offset as u32).checked_add(value_size as u32) {
|
||||
Some(0) => {}
|
||||
Some(x) => {
|
||||
a.emit_add(Size::S64, Location::Imm32(x), Location::GPR(tmp_addr));
|
||||
}
|
||||
@ -1541,11 +1542,13 @@ impl X64FunctionCode {
|
||||
|
||||
// Calculates the real address, and loads from it.
|
||||
a.emit_mov(Size::S32, addr, Location::GPR(tmp_addr));
|
||||
a.emit_add(
|
||||
Size::S64,
|
||||
Location::Imm32(offset as u32),
|
||||
Location::GPR(tmp_addr),
|
||||
);
|
||||
if offset != 0 {
|
||||
a.emit_add(
|
||||
Size::S64,
|
||||
Location::Imm32(offset as u32),
|
||||
Location::GPR(tmp_addr),
|
||||
);
|
||||
}
|
||||
a.emit_add(Size::S64, Location::GPR(tmp_base), Location::GPR(tmp_addr));
|
||||
m.release_temp_gpr(tmp_base);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user