fix: Hifi stack arrays#10905
Open
lgirdwood wants to merge 2 commits into
Open
Conversation
Force 8-byte alignment on abs_input_array in drc_update_detector_average(). The HiFi4 64-bit AE load/store intrinsics require 8-byte alignment; without it the stack buffer could be 4-byte aligned and trigger misaligned accesses. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
downmix16bit_4ch_mono() loads its coeffs[] array with AE_L16X4_X, an aligned 64-bit HiFi load that requires 8-byte alignment. The uint16_t stack array is only 2-byte aligned, so the compiler may place it on a 4-byte boundary and trigger a misaligned access. Force 8-byte alignment to match the intrinsic's requirement. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enforces stack alignment for small HiFi SIMD-consumed arrays to ensure they are safe to pass by pointer into vector load/store operations in the HiFi3/HiFi4 implementations.
Changes:
- Align the per-call downmix coefficient array in the HiFi3 up/down mixer to 8 bytes.
- Align the temporary per-division detector array in the HiFi4 DRC path to 8 bytes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/audio/up_down_mixer/up_down_mixer_hifi3.c | Aligns a stack coefficient array used for HiFi vector loads. |
| src/audio/drc/drc_hifi4.c | Aligns a stack working array used with HiFi vector load/store intrinsics. |
| uint32_t idx4 = get_channel_index(cd->in_channel_map, 3); | ||
|
|
||
| uint16_t coeffs[4] = {cd->downmix_coefficients[idx1], | ||
| uint16_t coeffs[4] __attribute__((aligned(8))) = {cd->downmix_coefficients[idx1], |
| { | ||
| ae_f32 detector_average = state->detector_average; /* Q2.30 */ | ||
| ae_int32 abs_input_array[DRC_DIVISION_FRAMES]; /* Q1.31 */ | ||
| ae_int32 abs_input_array[DRC_DIVISION_FRAMES] __attribute__((aligned(8))); /* Q1.31 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some arrays of hifi objects are on the stack, these should always be vector aligned since they can be consumed directly (passed via pointer) in SIMD operations. Enforce.