aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Tocar <ilya.tocar@intel.com>2017-12-07 10:56:45 -0600
committerIlya Tocar <ilya.tocar@intel.com>2018-02-14 19:56:57 +0000
commitde4edf3de7acda2cc7da8764ecdb3ff2e85c7a2d (patch)
tree6151cc9d479bc3d684577b3a87c704d6c3aba7b0 /src
parent9c4fd4626caefa0566e2d853c02912d559c01f62 (diff)
downloadgo-de4edf3de7acda2cc7da8764ecdb3ff2e85c7a2d.tar.xz
cmd/compile/internal/amd64: update popcnt code generation
Popcnt has false dependency on output register and generates MOVQ $0, reg to break it. But recently we switched MOVQ $0, reg encoding from xor reg, reg to actual mov $0, reg. This CL updates code generation for popcnt to use actual XOR. Change-Id: I4c1fc11e85758b53ba2679165fa55614ec54b27d Reviewed-on: https://go-review.googlesource.com/82516 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/amd64/ssa.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go
index e3129edbf1..49ef415e66 100644
--- a/src/cmd/compile/internal/amd64/ssa.go
+++ b/src/cmd/compile/internal/amd64/ssa.go
@@ -867,10 +867,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpAMD64POPCNTQ, ssa.OpAMD64POPCNTL:
if v.Args[0].Reg() != v.Reg() {
// POPCNT on Intel has a false dependency on the destination register.
- // Zero the destination to break the dependency.
- p := s.Prog(x86.AMOVQ)
- p.From.Type = obj.TYPE_CONST
- p.From.Offset = 0
+ // Xor register with itself to break the dependency.
+ p := s.Prog(x86.AXORQ)
+ p.From.Type = obj.TYPE_REG
+ p.From.Reg = v.Reg()
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
}