Browse Source
Per the P-extension spec, any instruction that performs saturation must set the vxsat CSR to 1 when the result is clamped. 70 instructions were missing this write, addressed here in two ways: 1. Convert P_SAT, P_USAT, and P_USAT_FULL macros from pure expression macros to GCC statement expressions that detect when saturation occurs and write P.VU.vxsat. This automatically fixes ~42 instructions that use these macros (nclip/nclipi/nclipr/nclipri families, psati, psslai, pssh1sadd, pusati, sati, usati, ssh1sadd, sslai, and their packed/double-wide variants). 2. Add explicit vxsat writes to 22 instructions with inline saturation logic that bypasses the macros: - mulq/mulqr/pmulq/pmulqr: set vxsat on INT_MIN * INT_MIN overflow - psas/pssa cross variants: set vxsat from sat_add/sat_sub sat flag - pssha/psshar DW variants: set vxsat from ov overflow flag - pssha/psshar/ssha/sshar: set vxsat in sshamt >= BIT overflow path - pusati_dh/pusati_dw: set vxsat on unsigned range clamping Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>pull/2246/head
25 changed files with 44 additions and 18 deletions
@ -1,7 +1,9 @@ |
|||
P_CROSS_ULOOP(16, { |
|||
bool sat = false; |
|||
p_rd = (sat_add<int16_t, uint16_t>(p_rs1, p_rs2, sat)); |
|||
if (sat) P.VU.vxsat->write(1); |
|||
}, { |
|||
bool sat = false; |
|||
p_rd = (sat_sub<int16_t, uint16_t>(p_rs1, p_rs2, sat)); |
|||
if (sat) P.VU.vxsat->write(1); |
|||
}) |
|||
@ -1,7 +1,9 @@ |
|||
P_CROSS_ULOOP(16, { |
|||
bool sat = false; |
|||
p_rd = (sat_sub<int16_t, uint16_t>(p_rs1, p_rs2, sat)); |
|||
if (sat) P.VU.vxsat->write(1); |
|||
}, { |
|||
bool sat = false; |
|||
p_rd = (sat_add<int16_t, uint16_t>(p_rs1, p_rs2, sat)); |
|||
if (sat) P.VU.vxsat->write(1); |
|||
}) |
|||
Loading…
Reference in new issue