aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-11-20 13:53:05 -0800
committerCarlos Amedee <carlos@golang.org>2020-12-03 13:58:28 +0000
commita2adbc876e9362f064afffcb51ce677e2f988c5e (patch)
treedd0eef170fd18e20dd1fc91a9d49f31054f928d4 /test
parent16ddb8bc763c33fb172d0c1bcd04d070f36f9cc8 (diff)
downloadgo-a2adbc876e9362f064afffcb51ce677e2f988c5e.tar.gz
go-a2adbc876e9362f064afffcb51ce677e2f988c5e.zip
[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 <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue42753.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/fixedbugs/issue42753.go b/test/fixedbugs/issue42753.go
new file mode 100644
index 0000000000..a998d1d3b3
--- /dev/null
+++ b/test/fixedbugs/issue42753.go
@@ -0,0 +1,13 @@
+// compile -d=ssa/check/on
+
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func f() uint32 {
+ s := "\x01"
+ x := -int32(s[0])
+ return uint32(x) & 0x7fffffff
+}