cmd/compile/internal/amd64: use appropriate NEG for div

Currently we generate NEGQ for DIV{Q,L,W}. By generating NEGL and NEGW,
we will reduce code size, because NEGL doesn't require rex prefix.
This also guarantees that upper 32 bits are zeroed, so we can revert CL 85736,
and remove zero-extensions of DIVL results.
Also adds test for redundant zero extend elimination.

Fixes #23310

Change-Id: Ic58c3104c255a71371a06e09d10a975bbe5df587
Reviewed-on: https://go-review.googlesource.com/96815
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Ilya Tocar 2018-02-23 13:46:44 -06:00
parent 3b7ad1680f
commit f4d9c30901
3 changed files with 44 additions and 6 deletions

View file

@ -782,12 +782,8 @@ func zeroUpper32Bits(x *Value, depth int) bool {
OpAMD64ANDL, OpAMD64ANDLconst, OpAMD64ORL, OpAMD64ORLconst,
OpAMD64XORL, OpAMD64XORLconst, OpAMD64NEGL, OpAMD64NOTL:
return true
case OpArg:
case OpArg, OpSelect0, OpSelect1:
return x.Type.Width == 4
case OpSelect0, OpSelect1:
// Disabled for now. See issue 23305.
// TODO: we could look into the arg of the Select to decide.
return false
case OpPhi:
// Phis can use each-other as an arguments, instead of tracking visited values,
// just limit recursion depth.