diff options
author | ChrisALiles <caveryliles@gmail.com> | 2018-08-06 19:50:38 +1000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-10-23 02:29:44 +0000 |
commit | 13d5cd784748f8849c75ec23ed6e3d40dc7d2ce7 (patch) | |
tree | 5bbce64c3e0bd9852e9c5111f474a22b61932389 /src/cmd/compile/internal/x86 | |
parent | 47cc59f31f8e2ef18ee34402be7b94cbe39638aa (diff) | |
download | go-13d5cd784748f8849c75ec23ed6e3d40dc7d2ce7.tar.gz go-13d5cd784748f8849c75ec23ed6e3d40dc7d2ce7.zip |
cmd/compile: use proved bounds to remove signed division fix-ups
prove is able to find 94 occurrences in std cmd where a divisor
can't have the value -1. The change removes
the extraneous fix-up code for these cases.
Fixes #25239
Change-Id: Ic184de971f47cc57c702eb72805b8e291c14035d
Reviewed-on: https://go-review.googlesource.com/c/130215
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/x86')
-rw-r--r-- | src/cmd/compile/internal/x86/ssa.go | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/x86/ssa.go b/src/cmd/compile/internal/x86/ssa.go index 8a6f015854..24ba9649be 100644 --- a/src/cmd/compile/internal/x86/ssa.go +++ b/src/cmd/compile/internal/x86/ssa.go @@ -198,24 +198,31 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { if v.Op == ssa.Op386DIVL || v.Op == ssa.Op386DIVW || v.Op == ssa.Op386MODL || v.Op == ssa.Op386MODW { - var c *obj.Prog + if ssa.NeedsFixUp(v) { + var c *obj.Prog + switch v.Op { + case ssa.Op386DIVL, ssa.Op386MODL: + c = s.Prog(x86.ACMPL) + j = s.Prog(x86.AJEQ) + + case ssa.Op386DIVW, ssa.Op386MODW: + c = s.Prog(x86.ACMPW) + j = s.Prog(x86.AJEQ) + } + c.From.Type = obj.TYPE_REG + c.From.Reg = x + c.To.Type = obj.TYPE_CONST + c.To.Offset = -1 + + j.To.Type = obj.TYPE_BRANCH + } + // sign extend the dividend switch v.Op { case ssa.Op386DIVL, ssa.Op386MODL: - c = s.Prog(x86.ACMPL) - j = s.Prog(x86.AJEQ) - s.Prog(x86.ACDQ) //TODO: fix - + s.Prog(x86.ACDQ) case ssa.Op386DIVW, ssa.Op386MODW: - c = s.Prog(x86.ACMPW) - j = s.Prog(x86.AJEQ) s.Prog(x86.ACWD) } - c.From.Type = obj.TYPE_REG - c.From.Reg = x - c.To.Type = obj.TYPE_CONST - c.To.Offset = -1 - - j.To.Type = obj.TYPE_BRANCH } // for unsigned ints, we sign extend by setting DX = 0 |