15 ms·
Huh, I naively expected constants to be loaded similar to 32-bit arm, where usually they come from a table of constants placed just after the function code itse
by jepler 5y ago
Huh, I naively expected constants to be loaded similar to 32-bit arm, where usually they come from a table of constants placed just after the function code itself. But both clang and gcc emit a series of mov + 3 movk for arbitrary constants. I guess the constant table is no more efficient on the size of the text segment, at least if the constant is unique, but adds a memory access that is not sequential, and might make the same cache line fight between I & D caches if they're exclusive.
Even if the same constant is used multiple times in the same function, it's still done in the same way. gcc with -Os can manage sometimes to turn it into a single constant load (moving it out of a case statement) but I didn't see either gcc or clang switch to pulling it from a constant table.