Avoid fetching instruction's first 16 bits twice.
The first instruction's 16 bits share the instruction's opcode and one or two
operands (depending on the instruction format). In the main interpreter loop,
we first load the first 16 bits of the instruction and keep only the low 8 bits
of the opcode.
Then we read the high 8 bits containing one 8-bits operand (vAA) or two 4-bits
operands (vA and vB). But currently, the GCC compiler does not make the link
with the opcode and reload the first 16 bits while a physical register already
This CL updates the Instruction::Opcode to use the Instruction::Fetch method so
the compiler makes the link between opcode and operand(s) and avoids loading
twice in most of instruction handling sequences.
Unfortunately, this does not fix all sequences and a few instructions remain
with this redundant 16-bits load. Sounds like we may not have enough control to
help the compiler do the right thing everytime.
1 file changed