Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

It's 2016 and COMPILERS ARE STILL STUPID

Name: Cudder !cXCudderUE 2015-12-31 22:29

Just analysing a device driver for hardware few months old... as usual, it's as bloated as a week-old dead pig overall but then I come across pieces like this:

shl ecx, 4
mov edx, ecx
shr ecx, 2
xor eax, eax
rep stosd
mov ecx, edx
and ecx, 3
rep stosb


:facepalm:

Name: Anonymous 2018-01-23 20:04

Check it out: C89 has restrict:
/* also try e.g. int, unsigned, long, double, etc */
#define type float

void add4(type *d, type *s, type *t) {
unsigned i;
for(i = 0; i < 4; ++i)
d[i] = s[i] + t[i];
}

void add4_r(type *d, type *s, type *t) {
type S[4], T[4];
unsigned i;
for(i = 0; i < 4; ++i)
S[i] = s[i], T[i] = t[i];
for(i = 0; i < 4; ++i)
d[i] = S[i] + T[i];
}

Name: Anonymous 2018-01-23 20:05

>>87
Result: 'add4()' produces shit code, 'add4_r()' produces nice SIMD code.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List