Den tors 12 dec. 2024 kl 16:57 skrev Christian Schulte <c...@schulte.it>:

> I am quite tired now and will need some sleep. I will try to come up
> with an example the next day. One using pointer syntax and a while loop
> and one using array syntax and a for loop. The first will make the
> compiler produce something similar to what I would have written in
> assembly directly. The latter will magically make the compiler start
> generating SIMD instructions. I may be very wrong about this and things
> just happened out of luck, but I'll give it a try the next day and
> report back.

I think modern compilers are really really good at figuring out that a
do {} while, a for() loop and all other kinds of constructs where you repeat
something until a condition is met are all alike and the intermediary
code, be it lisp-like as in gcc or a virtual bytecode thing for llvm-ir, will
look more or less the same in the middle of compilation, and in many
cases become the same output.

This mostly means that you could write the code in a readable and
understandable way, and let the compiler figure out the inner workings
of it, instead of having to type something really clever and convoluted
in the hopes that gcc3 on m88k will make a smarter loop of it, and in turn
confuse all developers on all other platforms with my perceived cleverness.

Looking at one compiler on one platform and making code style decisions
that affect some 10+ platforms using 3 different compilers is
probably not the wisest, even if that would be the most common one.


-- 
May the most significant bit of your life be positive.

Reply via email to