News for hackers. Stuff that matters.
Re:The x86 architecture is the weirdo (2004) by cesarb on Tuesday April 19, 2022 @04:05PM (#31088274)
> ARM introduced Thumb-2, with a mix of 2-byte and 4-byte instructions, in 2003. PowerPC and RISC-V also [...]

x86 is still the weirdo. Both Thumb-2 and the RISC-V C extension (I don't know about PowerPC) have only 2-byte and 4-byte instructions, aligned to 2 bytes; x86 instructions can vary from 1 to 15 bytes, with no alignment requirement.

Re:The x86 architecture is the weirdo (2004) by classichasclass on Tuesday April 19, 2022 @05:41PM (#31089647)
Power10 has prefixed instructions. These are essentially 64-bit instructions in two pieces. They are odd even (particularly?) to those of us who have worked with the architecture for a long time, and not much otherwise supports them yet. Their motivation is primarily to more efficiently represent constants and offsets.
Re:The x86 architecture is the weirdo (2004) by cryptonector on Tuesday April 19, 2022 @06:13PM (#31090007)
I suspect variable-length instructions are a big gain because you get to pack instructions more tightly and so have fewer cache misses. Though, obviously, it's going to depend on having an instruction set that yields shorter text for typical assembly than fixed-sized instructions would. (In a way, opcodes need a bit of Huffman encoding!)

Any losses from having to do more decoding work are probably offset by having sufficiently deep pipelines and enough decoders.

Re:The x86 architecture is the weirdo (2004) by phdelightful on Tuesday April 19, 2022 @06:32PM (#31090235)
The counterpoint is that variable-length decoding introduces sequential dependence in the decoding, i.e. you don’t know where instruction 2 starts until you’ve decoded instruction 1. This probably limits how many decoders you can have. If you know all your instructions are 4B you can basically decode as many as you want in parallel.
Re:The x86 architecture is the weirdo (2004) by astrange on Tuesday April 19, 2022 @07:59PM (#31091002)
A larger problem is that they're bad for security; you can hide malicious instructions from static analysis by jumping into the middle of a cleaner one. Or use it to find more ROP gadgets, etc.

I can imagine ways to deal with this, but x86 doesn't have them.

Re:The x86 architecture is the weirdo (2004) by gpderetta on Tuesday April 19, 2022 @07:35PM (#31090786)
I think what happen in practice is that the decoders still speculatively decode in parallel then drop all misdecoded instructions. Easy when instructions have only a couple of sizes. Hard and wasteful for something like x86.
Re:The x86 architecture is the weirdo (2004) by chasil on Tuesday April 19, 2022 @06:28PM (#31090195)
ARM Thumb actually licensed patents from Hitachi Super-H, who did this first.

Supposedly, "MIPS processors [also] have a MIPS-16 mode."

https://en.m.wikipedia.org/wiki/SuperH