[clang] [clang][Interp] Implement __builtin_rotate{right, left} (PR #72984)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 8 08:44:34 PST 2023
================
@@ -331,3 +331,17 @@ namespace bitreverse {
char bitreverse3[__builtin_bitreverse32(0x12345678) == 0x1E6A2C48 ? 1 : -1];
char bitreverse4[__builtin_bitreverse64(0x0123456789ABCDEFULL) == 0xF7B3D591E6A2C480 ? 1 : -1];
}
+
+namespace rotateleft {
+ char rotateleft1[__builtin_rotateleft8(0x01, 5) == 0x20 ? 1 : -1];
+ char rotateleft2[__builtin_rotateleft16(0x3210, 11) == 0x8190 ? 1 : -1];
+ char rotateleft3[__builtin_rotateleft32(0x76543210, 22) == 0x841D950C ? 1 : -1];
+ char rotateleft4[__builtin_rotateleft64(0xFEDCBA9876543210ULL, 55) == 0x87F6E5D4C3B2A19ULL ? 1 : -1];
+}
+
+namespace rotateright {
+ char rotateright1[__builtin_rotateright8(0x01, 5) == 0x08 ? 1 : -1];
+ char rotateright2[__builtin_rotateright16(0x3210, 11) == 0x4206 ? 1 : -1];
+ char rotateright3[__builtin_rotateright32(0x76543210, 22) == 0x50C841D9 ? 1 : -1];
+ char rotateright4[__builtin_rotateright64(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL ? 1 : -1];
----------------
AaronBallman wrote:
Ah, I was going off our public documentation which does not suggest that the value to be rotated is unsigned! Carry on.
https://github.com/llvm/llvm-project/pull/72984
More information about the cfe-commits
mailing list