]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: don't give credit for NOPs during register allocation
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 9 May 2014 16:55:17 +0000 (09:55 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 9 May 2014 16:55:17 +0000 (09:55 -0700)
commit1848d71445adc043b8c70cf80a36819b4b84efbd
tree8ccbc520e628ed25eb06f5f480b70f2138f797bb
parent52961b902fa89e89eff318e907e7f331bcf09736
cmd/gc: don't give credit for NOPs during register allocation

The register allocator decides which variables should be placed into registers by charging for each load/store and crediting for each use, and then selecting an allocation with minimal cost. NOPs will be eliminated, however, so using a variable in a NOP should not generate credit.

Issue 7867 arises from attempted registerization of multi-word variables because they are used in NOPs. By not crediting for that use, they will no longer be considered for registerization.

This fix could theoretically lead to better register allocation, but NOPs are rare relative to other instructions.

Fixes #7867.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/94810044
src/cmd/5g/reg.c
src/cmd/6g/reg.c
src/cmd/8g/reg.c
test/fixedbugs/issue7867.go [new file with mode: 0644]