Originally posted by cjcox
View Post
Announcement
Collapse
No announcement yet.
More Of The Linux Kernel's x86 Assembly Code Gets Rewritten In C
Collapse
X
-
Originally posted by gens View Postand no, compilers still don't match the performance of what an average assembly programmer can write
so you still have a TON of hand written assembly running on your computer
based on target architecture features like cache size, instructions supported, instruction combinations to avoid.
So while hand-tuned assembly might be faster on one particular cpu, a C compiler can output assembly almost as good
for any supported cpu. Also, C code is more readable than the avx-optimized x264 assembly code.
Comment
-
-
Originally posted by mlau View Post
Sure a compiler can't beat hand-scheduled and hand-tuned assembly code. However using C the compiler can then optimize
based on target architecture features like cache size, instructions supported, instruction combinations to avoid.
So while hand-tuned assembly might be faster on one particular cpu, a C compiler can output assembly almost as good
for any supported cpu. Also, C code is more readable than the avx-optimized x264 assembly code.
Compilers could do a better job if they get more hints from the programmer. C keywords like const and restrict are examples for such hints. If you use them properly then the compiler can generate good and fast code.
Comment
-
Originally posted by blubbaer View Post
A Compiler can't optimize for cache size or I havent seen one doing this. The programmer is responsible for designing the data structure to be cache friendly.
Compilers could do a better job if they get more hints from the programmer. C keywords like const and restrict are examples for such hints. If you use them properly then the compiler can generate good and fast code.
like alignment hints, inline, static etc
those are language hints and C is low enough to be able to have them
can it help the compiler make a faster function then a human could ?
no, not really
just look at something like glibc's sse2 memcpy, no compiler is able to make anything like that
i made a matrix multiplication function, that a compiler has even less chance of doing then that memcpy
some hints, that i think gcc extensions exists, that no "normal" C programmer would know how to use
and that is C, higher level languages do a lot worseLast edited by gens; 19 June 2015, 06:40 AM.
Comment
-
Originally posted by wizard69 View Post
This is the problem with assembly code, if it isn't well structured and documented even the original programmer will have trouble understanding it. It is very possible that nobody really knew what was going on with the code.
Comment
Comment