Theoretically, on modern processors that are faster:
- getting NOT result from the table
- or calculate it using operation
~(in C)?
Suppose the entire table is suitable for cache L1.
Bitwise:
uint8_t bitwise_not(uint8_t arg) { return ~arg; }
The table is not:
uint8_t table[0x100];
for (int i = 0; i < 0x100; ++i) { table[i] = ~static_cast<uint8_t>(i); }
uint8_t table_not(uint8_t arg) { return table[arg]; }
uint8_t xor_not(uint8_t arg) { return arg ^ 0xff; }
Not on one operation, but on several billion operations, reading from L1 cache is faster than any logical operation or not? (I think L1 is faster, but cannot prove it.)
Practically, how to measure it?
source
share