Why isn't "small" static code size the same as fast?

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
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
ISA (x86/armv8) q: Why isn't "gcc -Os" ~ "gcc -O3" ? (NT)anonymous22022/08/05 10:11 AM
  Why isn't "small" static code size the same as fast?Mark Roulo2022/08/05 12:10 PM
    Why isn't "small" static code size the same as fast?anonymous22022/08/05 02:05 PM
      Two examplesMark Roulo2022/08/05 02:20 PM
      Why isn't "small" static code size the same as fast?Andrey2022/08/05 04:08 PM
      Why isn't "small" static code size the same as fast?anon22022/08/05 05:33 PM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell tangerine? 🍊