Skip to content

Saturate Q15 variance results before narrowing - #355

Open
Firat17aze wants to merge 1 commit into
ARM-software:mainfrom
Firat17aze:fix/q15-variance-saturation
Open

Firat17aze wants to merge 1 commit into
ARM-software:mainfrom
Firat17aze:fix/q15-variance-saturation

Conversation

@Firat17aze

Copy link
Copy Markdown

Fixes #354.

arm_var_q15 documents that its 34.15 result is saturated to 1.15, but both the scalar and MVE paths assigned the shifted value directly to q15_t. A valid sample variance above 1.0 could therefore narrow to a negative result. This applies __SSAT(..., 16) before the assignment, matching the existing arm_std_q15 behavior.

Validation:

  • Built the full library in Release mode with HOST=ON and DISABLEFLOAT16=ON using AppleClang 21.
  • Ran a focused host reproducer at -O0 and at -O3 -ffast-math with loop unrolling. [0.75, -0.75] now saturates to 32767; an in-range case and the single-sample case remain unchanged.
  • Linked and ran the same reproducer against the built libCMSISDSP.a.
  • git diff --check passes.

No Arm hardware testing was performed, and the MVE path was not executed locally.

LLMs were used for review and code generation in some parts of this pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: arm_var_q15 wraps instead of applying the documented Q15 saturation

1 participant