From 9e7dbd0544babf7c0389a92ef439e4b04f0a3032 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Wed, 26 Feb 2020 13:44:41 +0100 Subject: [PATCH] mem-cache: Fix integer promotion of mask When applying the bitwise not to a short integer the compiler automatically promotes it to an integer. For example, if a 8-bit mask=0xFF, and the compiler decides to promote the mask to 32-bit to apply the bitwise not, ~mask=0xFFFFFF00, which will yield wrong results for popcount(): expected=0, got=24. Change-Id: I95efba5532c27ca004ff6947d4b51a8a14f09741 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33374 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- src/mem/cache/compressors/dictionary_compressor.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mem/cache/compressors/dictionary_compressor.hh b/src/mem/cache/compressors/dictionary_compressor.hh index fce79d5e8..650edab5a 100644 --- a/src/mem/cache/compressors/dictionary_compressor.hh +++ b/src/mem/cache/compressors/dictionary_compressor.hh @@ -464,7 +464,7 @@ class DictionaryCompressor::MaskedPattern const DictionaryEntry bytes, const bool allocate = true) : DictionaryCompressor::Pattern(number, code, metadata_length, - popCount(~mask), match_location, allocate), + popCount(static_cast(~mask)), match_location, allocate), bits(DictionaryCompressor::fromDictionaryEntry(bytes) & ~mask) { } -- 2.30.2