From f9de15be61e7bcdc98767ddfc9d8c79c1506608e Mon Sep 17 00:00:00 2001 From: Merry Date: Sat, 2 Jul 2022 22:12:13 +0100 Subject: [PATCH] encode: Only check MovImm16 encode size in hiiiiiiiiiiiiiiii case --- include/oaknut/impl/arm64_encode_helpers.inc.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/oaknut/impl/arm64_encode_helpers.inc.hpp b/include/oaknut/impl/arm64_encode_helpers.inc.hpp index 9ad601d..d70c670 100644 --- a/include/oaknut/impl/arm64_encode_helpers.inc.hpp +++ b/include/oaknut/impl/arm64_encode_helpers.inc.hpp @@ -39,9 +39,11 @@ template std::uint32_t encode(MovImm16 v) { static_assert(std::popcount(splat) == 17 || std::popcount(splat) == 18); - constexpr std::uint32_t mask = (1 << std::popcount(splat)) - 1; - if ((v.m_encoded & mask) != v.m_encoded) - throw "invalid MovImm16"; + if constexpr (std::popcount(splat) == 17) { + constexpr std::uint32_t mask = (1 << std::popcount(splat)) - 1; + if ((v.m_encoded & mask) != v.m_encoded) + throw "invalid MovImm16"; + } return detail::pdep(v.m_encoded, splat); }