ref: b08c8757a1150c6c63a82cecce20c2b128769408
parent: 247aa220f71b2c830ce5aa3d0a14588c250b360f
author: Siarhei Volkau <lis8215@gmail.com>
date: Sun Aug 24 06:52:05 EDT 2025
MIPS: allow __builtin_clz for MIPS32+ CLZ instruction first appeared in MIPS32 silk_CLZ16 and silk_CLZ32 can benefit of that, not DSP only. Signed-off-by: Siarhei Volkau <lis8215@gmail.com> Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
--- a/silk/mips/macros_mipsr1.h
+++ b/silk/mips/macros_mipsr1.h
@@ -29,10 +29,6 @@
#ifndef SILK_MACROS_MIPSR1_H__
#define SILK_MACROS_MIPSR1_H__
-static inline int mips_clz(opus_uint32 x)
-{
- return x ? __builtin_clz(x) : 32;
-}
#if defined (__mips_dsp) && __mips == 32
@@ -76,6 +72,25 @@
return res;
}
+#elif defined (__mips_isa_rev) && __mips == 32
+
+#undef silk_SMULWB
+static inline int silk_SMULWB(int a, int b)
+{
+ long long ac = (long long)a * (int)(b << 16);
+
+ return ac >> 32;
+}
+
+#endif
+
+#if defined (__mips_isa_rev) /* MIPS32r1+ */
+
+static inline int mips_clz(opus_uint32 x)
+{
+ return x ? __builtin_clz(x) : 32;
+}
+
#define OVERRIDE_silk_CLZ16
static inline opus_int32 silk_CLZ16(opus_int16 in16)
{
@@ -94,17 +109,6 @@
return re32;
}
-
-#elif defined (__mips_isa_rev) && __mips == 32
-
-#undef silk_SMULWB
-static inline int silk_SMULWB(int a, int b)
-{
- long long ac = (long long)a * (int)(b << 16);
-
- return ac >> 32;
-}
-
-#endif
+#endif /* __mips_isa_rev */
#endif /* SILK_MACROS_MIPSR1_H__ */
--
⑨