Open runer112 opened 1 week ago
All of them synthesize the operation (poorly)
int8_t
int16_t
int24_t
int32_t
int48_t
int64_t
uint48_t foo(uint48_t x) { return __builtin_bitreverse64(x) >> 16; }
__llbitrev
__i48bitrev
__builtin_bitreverse32(x >> 16) | (uint48_t)__builtin_bitreverse16(x) << 32
int24_t foo(int24_t x) { return __builtin_bswap32(x) >> 8; }
__lbswap
__ibswap
int48_t foo(int48_t x) { return __builtin_bswap64(x) >> 16; }
__llbswap
__i48bswap
int8_t foo(int8_t x, int8_t y) { return x / y; }
__sdivs
__bdivs
int16_t foo(int16_t x, int16_t y) { return x / y; }
__idivs
int48_t foo(int48_t x) { return -x; }
__i48abs
int8_t foo(int8_t x, int8_t y) { return x % y; }
__srems
__brems
int16_t foo(int16_t x, int16_t y) { return x % y; }
__irems
int8_t foo(int8_t x, int8_t y) { return x << y; }
__ishl
__bshl
int16_t foo(int16_t x, int16_t y) { return x << y; }
__sshl
int8_t foo(int8_t x, int8_t y) { return x >> y; }
__ishrs
uint8_t foo(uint8_t x, uint8_t y) { return x >> y; }
__ishru
__bshru
int16_t foo(int16_t x, int16_t y) { return x >> y; }
__sshrs
uint16_t foo(uint16_t x, uint16_t y) { return x >> y; }
__sshru
Absolute value
All of them synthesize the operation (poorly)
int8_t
int16_t
int24_t
int32_t
int48_t
int64_t
Bit reverse
uint48_t foo(uint48_t x) { return __builtin_bitreverse64(x) >> 16; }
uses__llbitrev
instead of__i48bitrev
(but__builtin_bitreverse32(x >> 16) | (uint48_t)__builtin_bitreverse16(x) << 32
is fine?)Byte swap
int24_t foo(int24_t x) { return __builtin_bswap32(x) >> 8; }
uses__lbswap
instead of__ibswap
(__ibswap
doesn't exist yet, but probably should?)int48_t foo(int48_t x) { return __builtin_bswap64(x) >> 16; }
uses__llbswap
instead of__i48bswap
? (can't confirm because of https://github.com/jacobly0/llvm-project/issues/44#issuecomment-2468738761)Division
int8_t foo(int8_t x, int8_t y) { return x / y; }
uses__sdivs
instead of__bdivs
int16_t foo(int16_t x, int16_t y) { return x / y; }
uses__idivs
instead of__sdivs
Negation
int48_t foo(int48_t x) { return -x; }
synthesizes the operation (poorly) instead of using__i48abs
Remainder
int8_t foo(int8_t x, int8_t y) { return x % y; }
uses__srems
instead of__brems
int16_t foo(int16_t x, int16_t y) { return x % y; }
uses__irems
instead of__srems
Shift left
int8_t foo(int8_t x, int8_t y) { return x << y; }
uses__ishl
instead of__bshl
int16_t foo(int16_t x, int16_t y) { return x << y; }
uses__ishl
instead of__sshl
Shift right
int8_t foo(int8_t x, int8_t y) { return x >> y; }
uses__ishrs
instead of__bshl
uint8_t foo(uint8_t x, uint8_t y) { return x >> y; }
uses__ishru
instead of__bshru
int16_t foo(int16_t x, int16_t y) { return x >> y; }
uses__ishrs
instead of__sshrs
uint16_t foo(uint16_t x, uint16_t y) { return x >> y; }
uses__ishru
instead of__sshru