arch-x86: fix negative overflow check bug in PACK micro-op (#332)

The implementation of the x86 PACK micro-op had a logical bug that
caused the `PACKSSWB` and `PACKSSDW` instructions to produce incorrect
results. Specifically, due to a signedness error, the overflow check for
negative integers being packed always evaluated to true, resulting in
all negative integers being packed as -1 in the output.

This patch fixes the signedness error that causes the bug.

GitHub issue: https://github.com/gem5/gem5/issues/331
This commit is contained in:
Bobby R. Bruce
2023-09-20 16:18:16 -07:00
committed by GitHub

View File

@@ -393,7 +393,7 @@ let {{
// Handle saturation.
if (signBit) {
if (overflow != mask(destBits - srcBits + 1)) {
if (overflow != mask(srcBits - destBits + 1)) {
if (signedOp())
picked = (1ULL << (destBits - 1));
else
@@ -421,7 +421,7 @@ let {{
// Handle saturation.
if (signBit) {
if (overflow != mask(destBits - srcBits + 1)) {
if (overflow != mask(srcBits - destBits + 1)) {
if (signedOp())
picked = (1ULL << (destBits - 1));
else