Fix slowness (bad static placement)

This commit is contained in:
msqr1
2024-09-27 11:44:46 -07:00
parent 7311d093e0
commit afc371d76b

View File

@@ -80,7 +80,7 @@ index 035ffee..18edcd3 100644
#endif
diff --git a/src/recognizer.cc b/src/recognizer.cc
index 55d9991..8671b71 100644
index 55d9991..5372a34 100644
--- a/src/recognizer.cc
+++ b/src/recognizer.cc
@@ -17,6 +17,7 @@
@@ -99,7 +99,6 @@ index 55d9991..8671b71 100644
bool Recognizer::AcceptWaveform(const float *fdata, int len)
-{
+{
+ static v128_t _32768fx4{wasm_f32x4_const_splat(32768.0f)};
Vector<BaseFloat> wave;
wave.Resize(len, kUndefined);
- for (int i = 0; i < len; i++)
@@ -107,11 +106,12 @@ index 55d9991..8671b71 100644
+ float* dst{wave.Data()};
+ int x4Len{len >> 2 << 2};
+ int i{};
+ for(;i < x4Len; i += 4, dst += 4, fdata += 4) {
+ wasm_v128_store(dst, wasm_f32x4_mul(wasm_v128_load(fdata), _32768fx4));
+ const v128_t _32768fx4{wasm_f32x4_const_splat(32768.0f)};
+ for(;i < x4Len; i += 4, dst += 4) {
+ wasm_v128_store(dst, wasm_f32x4_mul(wasm_v128_load(fdata + i), _32768fx4));
+ }
+ for(i = x4Len; i < len; ++i, ++fdata, ++dst) {
+ *dst = *fdata * 32768.0f;
+ for(i = x4Len; i < len; ++i, ++dst) {
+ *dst = fdata[i] * 32768.0f;
+ }
return AcceptWaveform(wave);
}