From ecff9c9335584a58ff6c45e71876ba60d982676c Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Sun, 8 Jan 2023 02:03:30 +1100 Subject: [PATCH] cmd/internal/obj/arm64: invert SP check Check for REGSP use before checking for invalid instructions. This simplifies the code and avoids duplicated op generation. Change-Id: I302e3b54a29742f2c48024b25162200f5966cfaa Reviewed-on: https://go-review.googlesource.com/c/go/+/461138 TryBot-Result: Gopher Robot Reviewed-by: Eric Fang Reviewed-by: Than McIntosh Run-TryBot: Joel Sing Reviewed-by: Cherry Mui --- src/cmd/internal/obj/arm64/asm7.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go index 5290aa11ef..f96efaee9d 100644 --- a/src/cmd/internal/obj/arm64/asm7.go +++ b/src/cmd/internal/obj/arm64/asm7.go @@ -3776,14 +3776,10 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) { case 24: /* mov/mvn Rs,Rd -> add $0,Rs,Rd or orr Rs,ZR,Rd */ rf := int(p.From.Reg) rt := int(p.To.Reg) - s := rf == REGSP || rt == REGSP - if p.As == AMVN || p.As == AMVNW { - if s { + if rf == REGSP || rt == REGSP { + if p.As == AMVN || p.As == AMVNW { c.ctxt.Diag("illegal SP reference\n%v", p) } - o1 = c.oprrr(p, p.As) - o1 |= (uint32(rf&31) << 16) | (REGZERO & 31 << 5) | uint32(rt&31) - } else if s { o1 = c.opirr(p, p.As) o1 |= (uint32(rf&31) << 5) | uint32(rt&31) } else { -- 2.50.0