From 8d4ec1c3ca8cf5546f63b30cc162833e8fa497b7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Dec 2024 13:30:29 +0530 Subject: [PATCH] Optimize get_min_scalefactor(), avoid IF --- lib_com/fft_fx.c | 27 +++++++++++++++++++++++++++ lib_com/options.h | 1 + 2 files changed, 28 insertions(+) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 13417b8c4..c4237bcc9 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -7284,6 +7284,7 @@ Word16 L_norm_arr( Word32 *arr, Word16 size ) Word16 get_min_scalefactor( Word32 x, Word32 y ) { +#ifndef FIX_1104_OPT_GETMINSCALEFAC Word16 scf = Q31; move16(); test(); @@ -7300,8 +7301,34 @@ Word16 get_min_scalefactor( Word32 x, Word32 y ) scf = s_min( scf, norm_l( y ) ); } return scf; +#else + Word16 scf_y; + Word16 scf = Q31; + move16(); + + test(); + if ( x == 0 && y == 0 ) + { + scf = 0; + move16(); + } + + if ( x != 0 ) + { + scf = norm_l( x ); + } + + scf_y = norm_l( y ); + if ( y != 0 ) + { + scf = s_min( scf_y, scf ); + } + + return scf; +#endif } + Flag is_zero_arr( Word32 *arr, Word16 size ) { FOR( Word16 i = 0; i < size; i++ ) diff --git a/lib_com/options.h b/lib_com/options.h index c86bbfcfb..686288b80 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,4 +94,5 @@ #define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */ #define FIX_1103_OPT_L_NORM_ARR /* FhG: Optimize L_norm_arr(), avoid IF */ #define FIX_1105_OPT_MINIMUM_SL /* FhG: Optimize minimum_s(), minimum_l(), avoid IF */ +#define FIX_1104_OPT_GETMINSCALEFAC /* FhG: Optimize get_min_scalefactor(), avoid IF */ #endif -- GitLab