0

Trying to rotate a 64 bit number by 4 bits but compiler not generating any code, warnings or errors.

        _rotl(X[h], 4);

_rotl,_rotl64, _rotr, _rotr64 - All produce no code.

_lrotl produced the following assembly code:

movsxd  rax, DWORD PTR h$13[rbp]
mov edx, 4
mov ecx, DWORD PTR X$[rbp+rax*4]
call    _lrotl

Have tried the console app example from the learn.microsoft.com page

_rotl64(val, 3) produces

mov edx, 3
mov rcx, QWORD PTR val2$[rbp]
call    _rotl64

As expected.

Adrian
  • 1
  • 1
  • I would probably remove the rotation tag since it's not meant to be used this way, and add the appropriate assembly tag(s) – Timothy G. Jul 27 '23 at 21:36

1 Answers1

0

Found answer halfway down

Best practices for circular shift (rotate) operations in C++

so added '#include <immintrin.h>' at the top of the affected file, compiler now produces the expected results:

; 390 : int o = _rotl64(X[h], 4) & 0x0f;

movsxd  rax, DWORD PTR h$13[rbp]
mov eax, DWORD PTR X$[rbp+rax*4]
rol rax, 4
and rax, 15
mov DWORD PTR o$15[rbp], eax
Adrian
  • 1
  • 1