From 23d4fb3362409bcbbb2298fe58e51d15ffa81d2c Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 17 Jul 2014 17:48:42 -0700 Subject: [PATCH] dsp/lossless: workaround gcc-4.9 bug on arm force Sub3() to not be inlined, otherwise the code in Select() will be incorrect. https://android-review.googlesource.com/#/c/102511 (cherry picked from commit 637b3888090dea7d79aa51731186938f8f0edf4d) Change-Id: I90ae58bf3e6cc92ca9897f69974733d562e29aaf --- src/dsp/lossless.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index 57d54a29..a1bf3584 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -450,12 +450,21 @@ static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1, return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b; } -static WEBP_INLINE int Sub3(int a, int b, int c) { +// gcc-4.9 on ARM generates incorrect code in Select() when Sub3() is inlined. +#if defined(__arm__) && LOCAL_GCC_VERSION == 0x409 +# define LOCAL_INLINE __attribute__ ((noinline)) +#else +# define LOCAL_INLINE WEBP_INLINE +#endif + +static LOCAL_INLINE int Sub3(int a, int b, int c) { const int pb = b - c; const int pa = a - c; return abs(pb) - abs(pa); } +#undef LOCAL_INLINE + static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) { const int pa_minus_pb = Sub3((a >> 24) , (b >> 24) , (c >> 24) ) +