From: Yi Kong Date: Thu, 28 Aug 2014 15:25:52 +0000 (+0000) Subject: arm_acle: Fix error in ROR implementation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b374ac9feff2c5e7f78741a2442ed64e2bfbe4d1;p=clang arm_acle: Fix error in ROR implementation The logic in calculating the rotate amount was flawed. Thanks Pasi Parviainen for pointing out! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216669 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/arm_acle.h b/lib/Headers/arm_acle.h index 8238323f5e..814df2c3d7 100644 --- a/lib/Headers/arm_acle.h +++ b/lib/Headers/arm_acle.h @@ -111,15 +111,15 @@ static __inline__ void __attribute__((always_inline, nodebug)) __nop(void) { /* ROR */ static __inline__ uint32_t __attribute__((always_inline, nodebug)) __ror(uint32_t x, uint32_t y) { - if (y == 0) return y; - if (y >= 32) y %= 32; + y %= 32; + if (y == 0) return x; return (x >> y) | (x << (32 - y)); } static __inline__ uint64_t __attribute__((always_inline, nodebug)) __rorll(uint64_t x, uint32_t y) { - if (y == 0) return y; - if (y >= 64) y %= 64; + y %= 64; + if (y == 0) return x; return (x >> y) | (x << (64 - y)); }