From d97dbb5f581736cff15feed97ebe307c0c6aa46f Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Thu, 11 Mar 2021 10:59:21 -0800 Subject: [PATCH] Enable bit mask immediate value check --- .../maple_be/src/cg/aarch64/aarch64_immediate.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_immediate.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_immediate.cpp index 399d293f25..858b40f9fe 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_immediate.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_immediate.cpp @@ -16,18 +16,14 @@ #include "common_utils.h" #include "mpl_logging.h" -#if DEBUG #include #include #include -#endif namespace maplebe { -#if DEBUG static std::set ValidBitmaskImmSet = { #include "valid_bitmask_imm.txt" }; -#endif namespace { constexpr uint32 kMaxBitTableSize = 5; @@ -45,13 +41,12 @@ bool IsBitmaskImmediate(uint64 val, uint32 bitLen) { if ((bitLen == k32BitSize) && (static_cast(val) == -1)) { return false; } -#if DEBUG uint64 val2 = val; if (bitLen == k32BitSize) { val2 = (val2 << k32BitSize) | (val2 & ((1ULL << k32BitSize) - 1)); } bool expectedOutcome = (ValidBitmaskImmSet.find(val2) != ValidBitmaskImmSet.end()); -#endif + if ((val & 0x1) != 0) { /* * we want to work with @@ -72,11 +67,12 @@ bool IsBitmaskImmediate(uint64 val, uint32 bitLen) { /* now check if tmp is a power of 2 or tmpVal==0. */ tmpVal = tmpVal & (tmpVal - 1); if (tmpVal == 0) { -#if DEBUG if (!expectedOutcome) { LogInfo::MapleLogger() << "0x" << std::hex << std::setw(k16ByteSize) << std::setfill('0') << static_cast(val) << "\n"; + return false; } +#if DEBUG ASSERT(expectedOutcome, "incorrect implementation: not valid value but returning true"); #endif /* power of two or zero ; return true */ -- Gitee