From: nimelehin Date: Mon, 6 Dec 2021 15:46:25 +0000 (+0300) Subject: cmd/compile: remove a false dependency for TZCNT X-Git-Tag: go1.19beta1~837 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=96081f854547353caaa77b795974f76b24572493;p=gostls13.git cmd/compile: remove a false dependency for TZCNT LZCNT/TZCNT on some Intel CPUs suffer from a false dependency on the destination register. The problem was mentioned in the GCC Ticket: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62011#c7 and fixed with https://gcc.gnu.org/viewcvs?rev=214112&root=gcc&view=rev Change-Id: I8109e84f03ac85f221b06d3b913612b58320d151 Reviewed-on: https://go-review.googlesource.com/c/go/+/369019 Reviewed-by: Keith Randall Trust: Alex Rakoczy Run-TryBot: Alex Rakoczy TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go index b0e5c34030..8ec54a8b03 100644 --- a/src/cmd/compile/internal/amd64/ssa.go +++ b/src/cmd/compile/internal/amd64/ssa.go @@ -265,8 +265,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { case ssa.OpAMD64BLSIQ, ssa.OpAMD64BLSIL, ssa.OpAMD64BLSMSKQ, ssa.OpAMD64BLSMSKL, - ssa.OpAMD64BLSRQ, ssa.OpAMD64BLSRL, - ssa.OpAMD64TZCNTQ, ssa.OpAMD64TZCNTL: + ssa.OpAMD64BLSRQ, ssa.OpAMD64BLSRL: p := s.Prog(v.Op.Asm()) p.From.Type = obj.TYPE_REG p.From.Reg = v.Args[0].Reg() @@ -1137,9 +1136,11 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.SetFrom3Reg(v.Args[0].Reg()) p.To.Type = obj.TYPE_REG p.To.Reg = v.Reg() - case ssa.OpAMD64POPCNTQ, ssa.OpAMD64POPCNTL: + case ssa.OpAMD64POPCNTQ, ssa.OpAMD64POPCNTL, + ssa.OpAMD64TZCNTQ, ssa.OpAMD64TZCNTL: if v.Args[0].Reg() != v.Reg() { - // POPCNT on Intel has a false dependency on the destination register. + // POPCNT/TZCNT/LZCNT have a false dependency on the destination register on Intel cpus. + // TZCNT/LZCNT problem affects pre-Skylake models. See discussion at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62011#c7. // Xor register with itself to break the dependency. p := s.Prog(x86.AXORL) p.From.Type = obj.TYPE_REG