1
0
mirror of https://github.com/golang/go synced 2024-11-19 12:14:42 -07:00

cmd/internal/obj/x86: minor optimization

- avoid copy in range ytab
- add fast path to prefixof

Change-Id: I88aa9d91a0abe80d253f7c3bca950b4613297499
Reviewed-on: https://go-review.googlesource.com/7628
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2015-03-13 11:58:13 -04:00
parent c8198344ef
commit 00b3b40b07

View File

@ -1903,6 +1903,9 @@ func instinit() {
} }
func prefixof(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { func prefixof(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
if a.Reg < REG_CS && a.Index < REG_CS { // fast path
return 0
}
if a.Type == obj.TYPE_MEM && a.Name == obj.NAME_NONE { if a.Type == obj.TYPE_MEM && a.Name == obj.NAME_NONE {
switch a.Reg { switch a.Reg {
case REG_CS: case REG_CS:
@ -2985,8 +2988,8 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
var r *obj.Reloc var r *obj.Reloc
var rel obj.Reloc var rel obj.Reloc
var v int64 var v int64
var yt ytab for i := range o.ytab {
for _, yt = range o.ytab { yt := &o.ytab[i]
if ycover[ft+int(yt.from)] != 0 && ycover[f3t+int(yt.from3)] != 0 && ycover[tt+int(yt.to)] != 0 { if ycover[ft+int(yt.from)] != 0 && ycover[f3t+int(yt.from3)] != 0 && ycover[tt+int(yt.to)] != 0 {
switch o.prefix { switch o.prefix {
case Px1: /* first option valid only in 32-bit mode */ case Px1: /* first option valid only in 32-bit mode */