2

I'm trying to perform a left circular shift (rol) under AMD64.

What is the equivalent intrinsic like the one provided by MSVC (_rotl64)?

Nocturnal
  • 673
  • 6
  • 25
  • There isn't one in VS: only _rotl8 and _rotl16. You could use the routines in http://www.devx.com/tips/Tip/14043 or inline assembler – cup Mar 11 '14 at 12:45
  • I tried to come up or look up any inline assembly to perform the desired task, but failed miserably. – Nocturnal Mar 11 '14 at 13:07
  • You might find that if you write the C code to do it, the compiler will notice you are rolling, and use the roll instruction. (I'd like to say "should" but I'm not that confident in the compilers' abilities!) – M.M Mar 11 '14 at 13:19
  • @MattMcNabb that's what I originally aimed for, but didn't get anything. – Nocturnal Mar 11 '14 at 13:24

1 Answers1

0
#include <stdint.h>

inline uint64_t rotl64 ( uint64_t x, int8_t r )
{
  return (x << r) | (x >> (64 - r));
}
Jun
  • 133
  • 4
  • 15