Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Include/dsp/none.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,13 @@ __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
uint64_t sum)
{
/* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
( ((q63_t)sum ) ) ));
/* Both products must be widened to 64-bit before they are summed: with
* both operands left as 32-bit `q31_t`, two same-sign near-full-scale
* products (each up to 2^30) sum to 2^31, which overflows signed 32-bit
* and wraps negative before ever reaching the 64-bit accumulator. */
return ((uint64_t)((q63_t)(((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16) +
(q63_t)(((q31_t)x ) >> 16) * (((q31_t)y ) >> 16) +
( (q63_t)sum ) ));
}


Expand All @@ -515,9 +519,10 @@ __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
uint64_t sum)
{
/* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
( ((q63_t)sum ) ) ));
/* See __SMLALD above: widen to 64-bit before summing the two products. */
return ((uint64_t)((q63_t)(((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16) +
(q63_t)(((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16) +
( (q63_t)sum ) ));
}


Expand Down