Skip to content

Commit b08c875

Browse files
SiarheiVolkaujmvalin
authored andcommitted
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 <[email protected]> Signed-off-by: Jean-Marc Valin <[email protected]>
1 parent 247aa22 commit b08c875

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

silk/mips/macros_mipsr1.h

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ POSSIBILITY OF SUCH DAMAGE.
2929
#ifndef SILK_MACROS_MIPSR1_H__
3030
#define SILK_MACROS_MIPSR1_H__
3131

32-
static inline int mips_clz(opus_uint32 x)
33-
{
34-
return x ? __builtin_clz(x) : 32;
35-
}
3632

3733
#if defined (__mips_dsp) && __mips == 32
3834

@@ -76,6 +72,25 @@ static inline int silk_SMLAWW(int a, int b, int c)
7672
return res;
7773
}
7874

75+
#elif defined (__mips_isa_rev) && __mips == 32
76+
77+
#undef silk_SMULWB
78+
static inline int silk_SMULWB(int a, int b)
79+
{
80+
long long ac = (long long)a * (int)(b << 16);
81+
82+
return ac >> 32;
83+
}
84+
85+
#endif
86+
87+
#if defined (__mips_isa_rev) /* MIPS32r1+ */
88+
89+
static inline int mips_clz(opus_uint32 x)
90+
{
91+
return x ? __builtin_clz(x) : 32;
92+
}
93+
7994
#define OVERRIDE_silk_CLZ16
8095
static inline opus_int32 silk_CLZ16(opus_int16 in16)
8196
{
@@ -94,17 +109,6 @@ static inline opus_int32 silk_CLZ32(opus_int32 in32)
94109
return re32;
95110
}
96111

97-
98-
#elif defined (__mips_isa_rev) && __mips == 32
99-
100-
#undef silk_SMULWB
101-
static inline int silk_SMULWB(int a, int b)
102-
{
103-
long long ac = (long long)a * (int)(b << 16);
104-
105-
return ac >> 32;
106-
}
107-
108-
#endif
112+
#endif /* __mips_isa_rev */
109113

110114
#endif /* SILK_MACROS_MIPSR1_H__ */

0 commit comments

Comments
 (0)