Skip to content

Commit 0aec8be

Browse files
committed
Bugfix in horizontal summing functions (invalid register clobber list)
1 parent 3e9f44a commit 0aec8be

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
=== 1.0.15 ===
66
* Fixed syntax error in C interface, covered with tests.
7+
* Bugfix in horizontal summing functions (invalid register clobber list).
78

89
=== 1.0.14 ===
910
* Implemented pcomplex_r2c instruction set.

include/private/dsp/arch/generic/hmath/hsum.h

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2020 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2023 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -33,17 +33,17 @@ namespace lsp
3333
float h_sum(const float *src, size_t count)
3434
{
3535
float result = 0.0f;
36-
while (count--)
37-
result += *(src++);
36+
for (size_t i=0; i<count; ++i)
37+
result += src[i];
3838
return result;
3939
}
4040

4141
float h_sqr_sum(const float *src, size_t count)
4242
{
4343
float result = 0.0f;
44-
while (count--)
44+
for (size_t i=0; i<count; ++i)
4545
{
46-
float tmp = *(src++);
46+
float tmp = src[i];
4747
result += tmp * tmp;
4848
}
4949
return result;
@@ -52,17 +52,11 @@ namespace lsp
5252
float h_abs_sum(const float *src, size_t count)
5353
{
5454
float result = 0.0f;
55-
while (count--)
56-
{
57-
float tmp = *(src++);
58-
if (tmp < 0.0f)
59-
result -= tmp;
60-
else
61-
result += tmp;
62-
}
55+
for (size_t i=0; i<count; ++i)
56+
result += fabsf(src[i]);
6357
return result;
6458
}
65-
}
66-
}
59+
} /* namespace generic */
60+
} /* namespace lsp */
6761

6862
#endif /* PRIVATE_DSP_ARCH_GENERIC_HMATH_HSUM_H_ */

include/private/dsp/arch/x86/avx/hmath/hsum.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2020 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2023 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -392,12 +392,13 @@ namespace lsp
392392
[res] "=Yz" (result)
393393
: [CC] "m" (h_abs_const)
394394
: "cc", "memory",
395-
"%xmm1"
395+
"%xmm1", "%xmm2", "%xmm3",
396+
"%xmm4", "%xmm5", "%xmm6", "%xmm7"
396397
);
397398

398399
return result;
399400
}
400-
}
401-
}
401+
} /* namespace avx */
402+
} /* namespace lsp */
402403

403404
#endif /* PRIVATE_DSP_ARCH_X86_AVX_HMATH_HSUM_H_ */

0 commit comments

Comments
 (0)