]> granicus.if.org Git - clang/commitdiff
arm_acle: Fix error in ROR implementation
authorYi Kong <Yi.Kong@arm.com>
Thu, 28 Aug 2014 15:25:52 +0000 (15:25 +0000)
committerYi Kong <Yi.Kong@arm.com>
Thu, 28 Aug 2014 15:25:52 +0000 (15:25 +0000)
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

lib/Headers/arm_acle.h

index 8238323f5e11ab3cc9c513168401cb2c6b448de9..814df2c3d782cfe188ac53fdb6fdbffbfea05e09 100644 (file)
@@ -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));
 }