ARM64: Use the zero register for zero constants when possible
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Tracking
()
People
(Reporter: lth, Unassigned)
References
(Blocks 1 open bug)
Details
This may be tricky to do except in limited contexts because of the risk of confusing the zero register with the stack pointer, and how often is the zero value used for anything but initialization anyway, but in principle when a zero value is needed we should use the zero register.
Consider
(func $f1 (param $p i32)
(i32.store (local.get $p) (i32.const 0)))
The code for this is:
0x13cf8746f034 52800001 mov w1, #0x0
0x13cf8746f038 b8206aa1 str w1, [x21, x0]
where the first instruction is not necessary, the second could just store wzr.
Similarly, in bug 1709863 the zero value shows up in an addressing instruction, and though that addressing code should be fixed in other ways and the particular issue will go away, the situation is the same: a zero literal should not need a dedicated register.
Reporter | ||
Comment 1•4 years ago
•
|
||
Integer negate has a redundant zero when expressed as 0-n instead of n*-1:
0x1e381ef2b084 52800001 mov w1, #0x0
0x1e381ef2b088 4b000020 sub w0, w1, w0
We probably want to handle this case during lowering and generate an LNegI node (we should do this cross-platform; x86/x64 have the same problem), and we want to check that a redundant zero is not being generated in this case.
(Addressed in bug 1710403.)
Description
•