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

circular shift

Name: Anonymous 2016-05-06 7:01

why don't most high level programming languages have a circular bitwise shift instructions given that most of the processors have it? why do I have to write a stupid one-liner that isn't guaranteed to be portable to have a compiler convert it to a single assembler instruction? it should be the other way around: write a single instruction and if processor doesn't support it, the compiler would convert it to an assembly workaround.

I know it's minor shit but that's also why there's no excuse for that

Name: Anonymous 2016-05-06 18:49

>>15
>>16
So? It's commonly done, though. n * sizeof(s) instead of n << log2(sizeof(s)). Similiarly with & and %. You write modulo because it's simply more readable, both compile to same thing (of course assuming power of 2 operand).

As for why there are no operators for obscure instructions like rotl, bswap, xlat, it's mainly because c was designed on/inspired by PDP7 in the 70s, not an 80286 in 2016.

To be frank, I'm more worried of the sorry state of x86 SIMD rotates, where you're simply forced to use four instructions - copy/shift/shift/or - no matter if it's hand written asm, or code generated by vectorizer, both compiles to the same crap (this was fixed only very recently, in AVX2).

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