[email protected] (Niels Möller) writes:

> I think current gcc may recognize (x << n) | (x >> (wordsize - n)) and
> generate a rotate instruction (but I haven't tested).

Now I have tested. gcc 4.4.5 seems to recognize it, even without
optimization.

Test program:

  #include <stdint.h>
  
  uint32_t rot32(uint32_t x, int k)
  {
    return (x << k) | (x >> (32-k));
  }
  
  uint32_t rot64(uint64_t x, int k)
  {
    return (x << k) | (x >> (64-k));
  }
    
Compile with gcc -S -O0, and examine the generated assembler.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to