From dc2facf9bee364794240a570c8741185972f7436 Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 27 Nov 2024 12:16:17 +0100 Subject: [PATCH 1/2] fix incorrect counting of complexity in the shr_ro() function --- lib_com/enh1632.c | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 1e6c41a0e..5dd147c26 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -410,12 +410,16 @@ Word16 shl_r( Word16 var1, Word16 var2 ) var_out = shr_r( var1, var2 ); #endif #ifdef WMOPS +#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shr_r--; +#endif #endif /* ifdef WMOPS */ } #ifdef WMOPS +#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shl_r++; +#endif #endif /* ifdef WMOPS */ return ( var_out ); diff --git a/lib_com/options.h b/lib_com/options.h index 03a1b1e92..cacefdab4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,4 +85,5 @@ #define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX #define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */ #define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */ +#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ #endif -- GitLab From df9846096279b9d6c45ecd7377f601ac68770f63 Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 6 Dec 2024 14:00:57 +0100 Subject: [PATCH 2/2] ensure proper incremenation/decremenation of shl/shr BASOP counters --- lib_com/basop32.c | 14 ++++++++++++++ lib_com/enh1632.c | 4 ---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib_com/basop32.c b/lib_com/basop32.c index 2a813e15c..dbdda3aeb 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -2825,6 +2825,11 @@ Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow ) { var_out = shr_o( var1, var2, Overflow ); +#ifdef FIX_1049_SHR_RO_COMPLEXITY +#ifdef WMOPS + multiCounter[currCounter].shr--; +#endif +#endif if ( var2 > 0 ) { if ( ( var1 & ( (Word16) 1 << ( var2 - 1 ) ) ) != 0 ) @@ -2833,6 +2838,15 @@ Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow ) } } } + +#ifdef FIX_1049_SHR_RO_COMPLEXITY +#ifdef WMOPS + multiCounter[currCounter].shr_r++; +#endif + + BASOP_CHECK(); +#endif + return ( var_out ); } Word16 shr_r_sat( Word16 var1, Word16 var2 ) diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 5dd147c26..1e6c41a0e 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -410,16 +410,12 @@ Word16 shl_r( Word16 var1, Word16 var2 ) var_out = shr_r( var1, var2 ); #endif #ifdef WMOPS -#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shr_r--; -#endif #endif /* ifdef WMOPS */ } #ifdef WMOPS -#ifndef FIX_1049_SHR_RO_COMPLEXITY multiCounter[currCounter].shl_r++; -#endif #endif /* ifdef WMOPS */ return ( var_out ); -- GitLab