From a2adbc876e9362f064afffcb51ce677e2f988c5e Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 20 Nov 2020 13:53:05 -0800 Subject: [release-branch.go1.15] cmd/compile: sign extend consant folding properly MOVLconst must have a properly sign-extended auxint constant. The bit operations in these rules don't enforce that invariant. The easiest fix is just to turn on properly typed auxint fields (which is what fixed this issue at tip). Fixes #42753 Change-Id: I264245fad45067a6ade65326f7fe681feb5f3739 Reviewed-on: https://go-review.googlesource.com/c/go/+/272028 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: David Chase --- src/cmd/compile/internal/ssa/gen/AMD64.rules | 6 +++--- src/cmd/compile/internal/ssa/rewriteAMD64.go | 18 +++++++++--------- test/fixedbugs/issue42753.go | 13 +++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 test/fixedbugs/issue42753.go diff --git a/src/cmd/compile/internal/ssa/gen/AMD64.rules b/src/cmd/compile/internal/ssa/gen/AMD64.rules index ee9ccfb41c..f7eb92dc8b 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/gen/AMD64.rules @@ -1429,11 +1429,11 @@ (NOTQ (MOVQconst [c])) -> (MOVQconst [^c]) (NOTL (MOVLconst [c])) -> (MOVLconst [^c]) (BTSQconst [c] (MOVQconst [d])) -> (MOVQconst [d|(1< (MOVLconst [d|(1< (MOVLconst [d|(1< (MOVQconst [d&^(1< (MOVLconst [d&^(1< (MOVLconst [d&^(1< (MOVQconst [d^(1< (MOVLconst [d^(1< (MOVLconst [d^(1<