Commit 00b3b40b authored by Russ Cox's avatar Russ Cox

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: 's avatarRob Pike <r@golang.org>
parent c8198344
......@@ -1903,6 +1903,9 @@ func instinit() {
}
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 {
switch a.Reg {
case REG_CS:
......@@ -2985,8 +2988,8 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
var r *obj.Reloc
var rel obj.Reloc
var v int64
var yt ytab
for _, yt = range o.ytab {
for i := 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 {
switch o.prefix {
case Px1: /* first option valid only in 32-bit mode */
......
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