PNCLIPUP.W: Packed Narrowing Unsigned Clip (64-bit to 32-bit).
Spike casts the 64-bit source registers to a signed 64-bit integer (sreg_t) before evaluating saturation. Because of this, any 64-bit input with the 63rd bit set (MSB = 1) is incorrectly evaluated as a negative number rather than as an unsigned number. This leads Spike to incorrectly saturate the result to 0x00000000 instead of the expected unsigned maximum 0xFFFFFFFF.
Example:
-
Input: rs1 = 0x8ed30e0630d20a98, rs2 = 0x83b9d1d6ae9ffccb
-
Operation:
-
Lane 0 (rs1): 0x8ed30e0630d20a98 >_u 0x00000000FFFFFFFF (True, must saturate to 0xFFFFFFFF)
-
Lane 1 (rs2): 0x83b9d1d6ae9ffccb >_u 0x00000000FFFFFFFF (True, must saturate to 0xFFFFFFFF)
-
Expected result: 0xFFFFFFFFFFFFFFFF
-
Spike result: 0x0000000000000000
Possible Cause: In the header file, s1 and s2 are explicitly cast to (sreg_t). When an input has the highest bit set to 1, the C++ cast interprets it as a negative value (< 0). The P_USAT_FULL macro detects a value less than zero and incorrectly clamps the final output to 0.
Possible Fix: Remove the (sreg_t) cast, or updated the clamping logic to explicitly handle 64-bit unsigned comparisons.
Spike hash : b2d6fbf
PNCLIPUP.W: Packed Narrowing Unsigned Clip (64-bit to 32-bit).
Spike casts the 64-bit source registers to a signed 64-bit integer (
sreg_t) before evaluating saturation. Because of this, any 64-bit input with the 63rd bit set (MSB = 1) is incorrectly evaluated as a negative number rather than as an unsigned number. This leads Spike to incorrectly saturate the result to0x00000000instead of the expected unsigned maximum0xFFFFFFFF.Possible Cause: In the header file,
s1ands2are explicitly cast to(sreg_t). When an input has the highest bit set to 1, the C++ cast interprets it as a negative value (< 0). TheP_USAT_FULLmacro detects a value less than zero and incorrectly clamps the final output to 0.Possible Fix: Remove the
(sreg_t)cast, or updated the clamping logic to explicitly handle 64-bit unsigned comparisons.Spike hash : b2d6fbf