]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix subword store/load elision for amd64, x86, arm
authorDavid Chase <drchase@google.com>
Tue, 30 May 2017 20:06:59 +0000 (16:06 -0400)
committerDavid Chase <drchase@google.com>
Tue, 30 May 2017 21:30:18 +0000 (21:30 +0000)
commit9613a638a95d5388f1f50189531a4e19af08fb15
tree038aea65ebcbe68b7602dcd646f827e377ee538d
parentd10549fb5763d33667ab02c0713c22c14f90078c
cmd/compile: fix subword store/load elision for amd64, x86, arm

Replacing byteload-of-bytestore-of-x with x is incorrect
when x contains a larger-than-byte value (and so on for
16 and 32-bit load/store pairs).  Replace "x" with the
appropriate zero/sign extension of x, which if unnecessary
will be repaired by other rules.

Made logic for arm match x86 and amd64; yields minor extra
optimization, plus I am (much) more confident it's correct,
despite inability to reproduce bug on arm.

Ppc64 lacks this optimization, hence lacks this problem.

See related https://golang.org/cl/37154/
Fixes #20530.

Change-Id: I6af9cac2ad43bee99cafdcb04725ce7e55a43323
Reviewed-on: https://go-review.googlesource.com/44355
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/386.rules
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/ARM.rules
src/cmd/compile/internal/ssa/rewrite386.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
src/cmd/compile/internal/ssa/rewriteARM.go
test/fixedbugs/issue20530.go [new file with mode: 0644]