By: Andrey (andrey.semashev.delete@this.gmail.com), August 5, 2022 4:08 pm
Room: Moderated Discussions
anonymous2 (anonymous2.delete@this.example.com) on August 5, 2022 2:05 pm wrote:
>
> Are the differences we see today the result of ISA/silicon/compiler evolution over time?
> Or is there are fundamental reason why they can't be _mostly_ the same thing?
>
> Smaller code fits more cache, it's rarely slower than unoptimized code (embedded anecdote).
Besides other optimization-wise reasons pointed out by Mark, optimizing for code size affects instruction selection. For example, dividing an integer by a small constant may be compiled to a multiply by a large constant and shift/offset for the fast code vs. actual divide instruction for the smaller code.
https://gcc.godbolt.org/z/Y6zcGKjE3
>
> Are the differences we see today the result of ISA/silicon/compiler evolution over time?
> Or is there are fundamental reason why they can't be _mostly_ the same thing?
>
> Smaller code fits more cache, it's rarely slower than unoptimized code (embedded anecdote).
Besides other optimization-wise reasons pointed out by Mark, optimizing for code size affects instruction selection. For example, dividing an integer by a small constant may be compiled to a multiply by a large constant and shift/offset for the fast code vs. actual divide instruction for the smaller code.
https://gcc.godbolt.org/z/Y6zcGKjE3
Topic | Posted By | Date |
---|---|---|
ISA (x86/armv8) q: Why isn't "gcc -Os" ~ "gcc -O3" ? (NT) | anonymous2 | 2022/08/05 10:11 AM |
Why isn't "small" static code size the same as fast? | Mark Roulo | 2022/08/05 12:10 PM |
Why isn't "small" static code size the same as fast? | anonymous2 | 2022/08/05 02:05 PM |
Two examples | Mark Roulo | 2022/08/05 02:20 PM |
Why isn't "small" static code size the same as fast? | Andrey | 2022/08/05 04:08 PM |
Why isn't "small" static code size the same as fast? | anon2 | 2022/08/05 05:33 PM |