-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile/internal: eliminate special branch psuedo-ops
The behavior of the RISCV BRANCH block is not safe. It reaches into the control value and uses the registers of the control's args, rather than the control value itself. regalloc ensures that the control value is in a register, but it does *not* do so for the control's arguments. It does not know that BRANCH uses them and thus may not consider them live. The reason for this weird BRANCH behavior is that RISC-V branches are binary instructions, comparing two operands to decide which branch to take, but we only have one control value, not two. The best way to solve this would be to teach the compiler than some blocks need two control values. While that doesn't look too difficult to implement, it is a fairly large scale, intrusive change to the compiler. Maintaining these changes as upstream continues to change the compiler would become a painful maintainance burden. Instead, make the branches behave much more like other architectures, where the condition comparision is done in an instruction before the branch. We then generate a branch instruction that simply compares the condition with zero. Once we are merged upstream, we can come back and investigate generating better code by adding a second control value. Fixes golang#12 Change-Id: I926d7ea45973c88927d42e915eb68265e79eb345
- Loading branch information
Showing
5 changed files
with
20 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.