Fix vector mult function for out of bound access
This commit is contained in:
@@ -30,28 +30,30 @@ void multadd_complex_vector_real_scalar(int16_t *x,
|
||||
uint8_t zero_flag,
|
||||
uint32_t N)
|
||||
{
|
||||
|
||||
simd_q15_t alpha_128,*x_128=(simd_q15_t *)x,*y_128=(simd_q15_t*)y;
|
||||
int n;
|
||||
|
||||
alpha_128 = set1_int16(alpha);
|
||||
const uint32_t num_adds = (N + 3) / 4; // ceil(N/4)
|
||||
const uint32_t num_simd_adds = N / 4;
|
||||
const uint32_t num_adds = N % 4;
|
||||
|
||||
if (zero_flag == 1) {
|
||||
for (n = 0; n < num_adds; n++) {
|
||||
// print_shorts("x_128[n]=", &x_128[n]);
|
||||
// print_shorts("alpha_128", &alpha_128);
|
||||
for (n = 0; n < num_simd_adds; n++) {
|
||||
y_128[n] = mulhi_int16(x_128[n],alpha_128);
|
||||
// print_shorts("y_128[n]=", &y_128[n]);
|
||||
}
|
||||
for (n = 0; n < num_adds; n++) {
|
||||
const uint32_t offset = num_simd_adds * 4;
|
||||
y[offset + n] = (x[offset + n] * alpha) >> 16;
|
||||
}
|
||||
} else {
|
||||
for (n = 0; n < num_adds; n++) {
|
||||
for (n = 0; n < num_simd_adds; n++) {
|
||||
y_128[n] = adds_int16(y_128[n],mulhi_int16(x_128[n],alpha_128));
|
||||
}
|
||||
for (n = 0; n < num_adds; n++) {
|
||||
const uint32_t offset = num_simd_adds * 4;
|
||||
y[offset + n] += (x[offset + n] * alpha) >> 16;
|
||||
}
|
||||
}
|
||||
|
||||
simde_mm_empty();
|
||||
simde_m_empty();
|
||||
}
|
||||
|
||||
void multadd_real_vector_complex_scalar(const int16_t *x, const int16_t *alpha, int16_t *y, uint32_t N)
|
||||
|
||||
Reference in New Issue
Block a user