This is probably the register allocator making a nonoptimal choice.
There's a phi operation which is merging arr[i] and max. arr[i] is in SI and max is in DX. It decides to put the phi result in SI. It would be better to put in in DX because it needs to end up in DX for the next iteration. The code is just arbitrarily picking between the registers of the phi inputs, and chooses wrong. Looks like phi register allocation could use some lookahead when there are multiple good choices for the phi register.
The real question is why this code isn't generating conditional moves. Looks like branchelim doesn't quite work because prove has left some dead code around that confuses branchelim. Hmmm...
What version of Go are you using (
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
centos8 & amd64
What did you do?
Given the code:
What did you expect to see?
What did you see instead?
The above assembly code has 2 more invalid move operations than the first code. Can someone help explain the reason?
The text was updated successfully, but these errors were encountered: