[a64] Optimize constant vector byte-splats

Detect when all bytes are repeating and use `MOVI` when applicable
This commit is contained in:
Wunkolo 2024-05-25 15:47:18 -07:00
parent fc1a13d3b2
commit bf12583b9e
1 changed files with 4 additions and 0 deletions

View File

@ -857,6 +857,10 @@ void A64Emitter::LoadConstantV(oaknut::QReg dest, const vec128_t& v) {
} else if (v.low == ~uint64_t(0) && v.high == ~uint64_t(0)) {
// 1111...
MOVI(dest.B16(), 0xFF);
} else if (std::adjacent_find(std::cbegin(v.u8), std::cend(v.u8),
std::not_equal_to<>()) == std::cend(v.u8)) {
// 0xXX, 0xXX, 0xXX...
MOVI(dest.B16(), v.u8[0]);
} else {
// TODO(benvanik): see what other common values are.
// TODO(benvanik): build constant table - 99% are reused.