Commit de4edf3d authored by Ilya Tocar's avatar Ilya Tocar

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: 's avatarKeith Randall <khr@golang.org>
parent 9c4fd462
...@@ -867,10 +867,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { ...@@ -867,10 +867,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpAMD64POPCNTQ, ssa.OpAMD64POPCNTL: case ssa.OpAMD64POPCNTQ, ssa.OpAMD64POPCNTL:
if v.Args[0].Reg() != v.Reg() { if v.Args[0].Reg() != v.Reg() {
// POPCNT on Intel has a false dependency on the destination register. // POPCNT on Intel has a false dependency on the destination register.
// Zero the destination to break the dependency. // Xor register with itself to break the dependency.
p := s.Prog(x86.AMOVQ) p := s.Prog(x86.AXORQ)
p.From.Type = obj.TYPE_CONST p.From.Type = obj.TYPE_REG
p.From.Offset = 0 p.From.Reg = v.Reg()
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg() p.To.Reg = v.Reg()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment