arch-x86: fix negative overflow check bug in PACK micro-op

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

Change-Id: I44b7328a8ce31742a3c0dfaebd747f81751e8851
This commit is contained in:
Nicholas Mosier
2023-09-20 05:09:32 +00:00
parent 3bdcfd6f7a
commit 741a901d8d

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