-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible shift by negative amount in modules arm_lms_norm_q31 and am_lms_norm_q15 #106
Comments
More specifically, the compiler warning is about https://github.com/ARM-software/CMSIS-DSP/blob/6ae4fa55482ea91b837ca9113070671bbc4b406e/Source/FilteringFunctions/arm_lms_norm_q31.c#LL189, where a negative shift value cannot be ruled out. |
@elagil I don't think it can happen. The only risk may be that energy overflow. But in that case, the algorithm will not work. The energy would overflow only if the signal is diverging from the reference. |
If Would you consider adding an |
From the user point of view, if energy saturates and becomes negative, it means the filter has already strongly diverged and so the results are meaningless. In this context, if the algorithm is no more right it is not really a problem. But if we want to give enough information to the compiler to remove some warnings, then perhaps the simplest is to saturate the energy. Before the >>32 and cast to q31_t, we could check if the int64 value is negative and in this case, return 0x7FFFFFFF for the int32 result. For this operation that may saturate: |
I am not sure, which line of the code you are referencing. In any case, I agree that mitigating compiler warnings by catching this undefined case is a good idea. |
Energy saturation in fixed point for lms norm
@elagil I have made more tests with a relatively long filter (150 taps). In q31, when energy is saturating, the signal part of the algorithm is also saturating. |
Thanks for your efforts! That sounds good to me. |
Energy saturation in fixed point for lms norm
This raises the original issue from ARM-software/CMSIS_5#1567, which is now out of scope there.
In brief:
"Compiling current CMSIS for Host platfom (AMD64) while gcc's static code analysis feature is active, results in serious looking errors."
The text was updated successfully, but these errors were encountered: