Live data from Hacker News

80386 Barrel Shifter

nand2mario.github.io

11–14 of 14 posts

Re: 80386 Barrel Shifter

#11
post #10

Earlier quoted context omitted.

So you can have bit arrays of any length in memory, rather than just 32 bits in a register.

That makes sense. LLVM could probably do better here by using the memory operand version: https://godbolt.org/z/jeqbaPsMz

The memory operand version tends to be as slow or slower than the manual implementation, so LLVM is right to avoid it.

Re: 80386 Barrel Shifter

#12
post #10

Earlier quoted context omitted.

So you can have bit arrays of any length in memory, rather than just 32 bits in a register.

That makes sense. LLVM could probably do better here by using the memory operand version: https://godbolt.org/z/jeqbaPsMz

Don't think the memory operand version would work here. If I understand the x86 architectural manual description, the 32-bit operand form interprets the bit offset as signed. A 64-bit operand could work around that but then run into issues with over-read due to fetching 64 bits of data.

Re: 80386 Barrel Shifter

#13

Implementing rotate through carry like that was a really bad decision IMO - it's almost never by more than one bit left or right at a time, and this could be done much more efficiently than with the constant-time code which is only faster when the count is > 6. Is the full microcode available anywhere?

Except that there are tremendous advantages to constant-time execution, not the least of which is protection from timing security attacks/information leakage (which admittedly were less of a concern back then). Sure you can get the one instruction executed for the <6 case faster, but the transistor budget for that isn't worth it, particularly if you pipeline the execution into stages. It makes optimization far more complex...

Re: 80386 Barrel Shifter

#14
post #11
post #10

Earlier quoted context omitted.

That makes sense. LLVM could probably do better here by using the memory operand version: https://godbolt.org/z/jeqbaPsMz

The memory operand version tends to be as slow or slower than the manual implementation, so LLVM is right to avoid it.

Right, it has much worse throughput:

Memory: https://uica.uops.info/tmp/f022a3c0a70e4ae5ab3588ebe65fd2a5_...

Register: https://uica.uops.info/tmp/e80e60e0c4914955b11dc6590711c1b8_...

Post reply on HN