On Sat, 5 Jul 2025 15:15:57 -0500 Segher Boessenkool <seg...@kernel.crashing.org> wrote:
... > The isel machine instruction is super expensive on p8: it is marked as > first in an instruction group, and has latency 5 for the GPR sources, > and 8 for the CR field source. > > On p7 it wasn't great either, it was actually converted to a branch > sequence internally! Ugg... You'd think they'd add instructions that can be implemented. It isn't as though isel is any harder than 'add with carry'. Not that uncommon, IIRC amd added adox/adcx (add carry using the overflow/carry flag and without changing any other flags) as very slow instructions. Intel invented them without making jcxz (dec %cx and jump non-zero) fast - so you can't (easily) put them in a loop. Not to mention all the AVX512 fubars. Conditional move is more of a problem with a mips-like cpu where alu ops read two registers and write a third. You don't want to do a conditional write because it messes up the decision of whether to forward the alu result to the following instruction. So I think you might need to do 'cmov odd/even' and read the LSB from a third copy (or third read port) of the registers indexed by what would normally be the 'output' register number. Then tweak the register numbers early in the pipeline so that the result goes to one of the 'input' registers rather than the normal 'output' one. Not really that hard - could add to the cpu I did in 1/2 a day :-) David