From: isharipo Date: Fri, 6 Apr 2018 19:22:03 +0000 (+0300) Subject: cmd/internal/obj/x86: remove redundant code (fix TODO) X-Git-Tag: go1.11beta1~918 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=67cc1af133a2917e8f6ef4bd08b1251695fd2346;p=gostls13.git cmd/internal/obj/x86: remove redundant code (fix TODO) Special cases described in TODO comments are fixed in https://golang.org/cl/6901. One of those blocks was needed until old 6a assembler was removed. This happened in https://golang.org/cl/12784. Fixes #24734 (Also contains more details and reasoning) Change-Id: If1f2f155d36ab236b16ae6f309a0716e00aa6371 Reviewed-on: https://go-review.googlesource.com/105156 Run-TryBot: Iskander Sharipov TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index d817a89af7..29a87d79a3 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -3739,7 +3739,7 @@ func regIndex(r int16) int { // Reports errors via ctxt. func avx2gatherValid(ctxt *obj.Link, p *obj.Prog) bool { // If any pair of the index, mask, or destination registers - // are the same, this instruction results a #UD fault. + // are the same, illegal instruction trap (#UD) is triggered. index := regIndex(p.GetFrom3().Index) mask := regIndex(p.From.Reg) dest := regIndex(p.To.Reg) @@ -3768,38 +3768,9 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) { ab.Put1(byte(pre)) } - // TODO(rsc): This special case is for SHRQ $3, AX:DX, - // which encodes as SHRQ $32(DX*0), AX. - // Similarly SHRQ CX, AX:DX is really SHRQ CX(DX*0), AX. - // Change encoding generated by assemblers and compilers and remove. - if (p.From.Type == obj.TYPE_CONST || p.From.Type == obj.TYPE_REG) && p.From.Index != REG_NONE && p.From.Scale == 0 { - p.SetFrom3(obj.Addr{ - Type: obj.TYPE_REG, - Reg: p.From.Index, - }) - p.From.Index = 0 - } - - // TODO(rsc): This special case is for PINSRQ etc, CMPSD etc. - // Change encoding generated by assemblers and compilers (if any) and remove. + // Сhecks to warn about instruction/arguments combinations that + // will unconditionally trigger illegal instruction trap (#UD). switch p.As { - case AIMUL3Q, APEXTRW, APINSRW, APINSRD, APINSRQ, APSHUFHW, APSHUFL, APSHUFW, ASHUFPD, ASHUFPS, AAESKEYGENASSIST, APSHUFD, APCLMULQDQ: - if p.From3Type() == obj.TYPE_NONE { - p.SetFrom3(p.From) - p.From = obj.Addr{} - p.From.Type = obj.TYPE_CONST - p.From.Offset = p.To.Offset - p.To.Offset = 0 - } - case ACMPSD, ACMPSS, ACMPPS, ACMPPD: - if p.From3Type() == obj.TYPE_NONE { - p.SetFrom3(p.To) - p.To = obj.Addr{} - p.To.Type = obj.TYPE_CONST - p.To.Offset = p.GetFrom3().Offset - p.GetFrom3().Offset = 0 - } - case AVGATHERDPD, AVGATHERQPD, AVGATHERDPS,