aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
28 hourscmd/compile/internal/ssa: cleanup ANDCCconst rewrite rules on PPC64Paul E. Murphy
Avoid creating duplicate usages of ANDCCconst. This is preparation for a patch to reintroduce ANDconst to simplify the lower pass while treating ANDCCconst like other *CC* ssa opcodes. Also, move many of the similar rules wich retarget ANDCCconst users to the flag result to a common rule for all compares against zero. Change-Id: Ida86efe17ff413cb82c349d8ef69d2899361f4c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/585400 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
3 dayscmd/compile: add test case for using Alias typesCuong Manh Le
CL 579935 disabled usage of Alias types in the compiler, and tracks the problem with issue #66873. The test case in #65893 passes now with the current tip. This CL adds a test case to ensure there is no regression once Alias types are enabled for the compiler. Updates #66873 Fixes #65893 Change-Id: I51b51bb13ca59549bc5925dd95f73da40465556d Reviewed-on: https://go-review.googlesource.com/c/go/+/568455 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 dayscmd/compile: disallow linkname referring to instantiationsCherry Mui
Linknaming an instantiated generic symbol isn't particularly useful: it doesn't guarantee the instantiation exists, and the instantiated symbol name may be subject to change. Checked with a large code corpus, currently there is no occurrance of linkname to an instantiated generic symbol (or symbol with a bracket in its name). This also suggests that it is not very useful. Linkname is already an unsafe mechanism. We don't need to allow it to do more unsafe things without justification. Change-Id: Ifaa20c98166b28a9d7dc3290c013c2b5bb7682e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/585458 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
3 dayscmd/compile/internal/noder: enable type aliases in type checkerMatthew Dempsky
This CL fixes an initialization loop during IR construction, that stems from IR lacking first-class support for aliases. As a workaround, we avoid publishing alias declarations until the RHS type expression has been constructed. Thanks to gri@ for investigating while I was out. Fixes #66873. Change-Id: I11e0d96ea6c357c295da47f44b6ec408edef89b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/585399 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
3 dayscmd/compile/internal/ssa: combine more shift and masking on PPC64Paul E. Murphy
Investigating binaries, these patterns seem to show up frequently. Change-Id: I987251e4070e35c25e98da321e444ccaa1526912 Reviewed-on: https://go-review.googlesource.com/c/go/+/583302 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 dayscmd/compile: avoid past-the-end pointer when zeroingKeith Randall
When we optimize append(s, make([]T, n)...), we have to be careful not to pass &s[0] + len(s)*sizeof(T) as the argument to memclr, as that pointer might be past-the-end. This can only happen if n is zero, so just special-case n==0 in the generated code. Fixes #67255 Change-Id: Ic680711bb8c38440eba5e759363ef65f5945658b Reviewed-on: https://go-review.googlesource.com/c/go/+/584116 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
12 dayscmd/compile: don't combine loads in generated equality functionskhr@golang.org
... if the architecture can't do unaligned loads. We already handle this in a few places, but this particular place was added in CL 399542 and missed this additional restriction. Fixes #67160 Change-Id: I45988f11ff3ed45df1c4da3f0931ab1fdb22dbfe Reviewed-on: https://go-review.googlesource.com/c/go/+/583175 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Derek Parker <parkerderek86@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-03cmd/compile/internal/ssa: on PPC64, try combining CLRLSLDI and SRDconst into ↵Paul E. Murphy
RLWINM This provides a small performance bump to crc64 as measured on ppc64le/power10: name old time/op new time/op delta Crc64/ISO64KB 49.6µs ± 0% 46.6µs ± 0% -6.18% Crc64/ISO4KB 3.16µs ± 0% 2.97µs ± 0% -5.83% Crc64/ISO1KB 840ns ± 0% 794ns ± 0% -5.46% Crc64/ECMA64KB 49.6µs ± 0% 46.5µs ± 0% -6.20% Crc64/Random64KB 53.1µs ± 0% 49.9µs ± 0% -6.04% Crc64/Random16KB 15.9µs ± 1% 15.0µs ± 0% -5.73% Change-Id: I302b5431c7dc46dfd2d211545c483bdcdfe011f1 Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power9,gotip-linux-ppc64le_power10 Reviewed-on: https://go-review.googlesource.com/c/go/+/581937 Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Eli Bendersky <eliben@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2024-04-19cmd/compile: remove redundant calls to cmpstringkhr@golang.org
The results of cmpstring are reuseable if the second call has the same arguments and memory. Note that this gets rid of cmpstring, but we still generate a redundant </<= test and branch afterwards, because the compiler doesn't know that cmpstring only ever returns -1,0,1. Update #61725 Change-Id: I93a0d1ccca50d90b1e1a888240ffb75a3b10b59b Reviewed-on: https://go-review.googlesource.com/c/go/+/578835 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-04-09cmd/compile/internal: merge stack slots for selected local auto varsThan McIntosh
[This is a partial roll-forward of CL 553055, the main change here is that the stack slot overlap operation is flagged off by default (can be enabled by hand with -gcflags=-d=mergelocals=1) ] Preliminary compiler support for merging/overlapping stack slots of local variables whose access patterns are disjoint. This patch includes changes in AllocFrame to do the actual merging/overlapping based on information returned from a new liveness.MergeLocals helper. The MergeLocals helper identifies candidates by looking for sets of AUTO variables that either A) have the same size and GC shape (if types contain pointers), or B) have the same size (but potentially different types as long as those types have no pointers). Variables must be greater than (3*types.PtrSize) in size to be considered for merging. After forming candidates, MergeLocals collects variables into "can be overlapped" equivalence classes or partitions; this process is driven by an additional liveness analysis pass. Ideally it would be nice to move the existing stackmap liveness pass up before AllocFrame and "widen" it to include merge candidates so that we can do just a single liveness as opposed to two passes, however this may be difficult given that the merge-locals liveness has to take into account writes corresponding to dead stores. This patch also required a change to the way ssa.OpVarDef pseudo-ops are generated; prior to this point they would only be created for variables whose type included pointers; if stack slot merging is enabled then the ssagen code creates OpVarDef ops for all auto vars that are merge candidates. Note that some temporaries created late in the compilation process (e.g. during ssa backend) are difficult to reason about, especially in cases where we take the address of a temp and pass it to the runtime. For the time being we mark most of the vars created post-ssagen as "not a merge candidate". Stack slot merging for locals/autos is enabled by default if "-N" is not in effect, and can be disabled via "-gcflags=-d=mergelocals=0". Fixmes/todos/restrictions: - try lowering size restrictions - re-evaluate the various skips that happen in SSA-created autotmps Updates #62737. Updates #65532. Updates #65495. Change-Id: Ifda26bc48cde5667de245c8a9671b3f0a30bb45d Reviewed-on: https://go-review.googlesource.com/c/go/+/575415 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-04-05cmd/compile: export/import materialized aliasesAlan Donovan
This CL changes the compiler's type import/export logic to create and preserve materialized Alias types when GODEBUG=gotypesaliases=1. In conjunction with CL 574717, it allows the x/tools tests to pass with GODEBUG=gotypesaliases=1. Updates #65294 Updates #64581 Fixes #66550 Change-Id: I70b9279f4e0ae7a1f95ad153c4e6909a878915a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/574737 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2024-04-04cmd/internal/obj/ppc64: on Power10, use xxspltidp for float constantsPaul E. Murphy
Any normal float32 constant can be generated by this instruction; use xxspltidp when possible. This prefixed instruction is much faster than the two instruction load sequence from the float32/float64 constant pool. Change-Id: Id751d9ffdae71463adbde66427b986f0b2ef74c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/575555 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Paul Murphy <murp@ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2024-04-04all: fix some commentscui fliter
Change-Id: I0ee85161846c13d938213ef04d3a34f690a93e48 Reviewed-on: https://go-review.googlesource.com/c/go/+/553435 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-02cmd/compile: add missing OASOP case in mayModifyPkgVarCuong Manh Le
CL 395541 made staticopy safe, stop applying the optimization once seeing an expression that may modify global variables. However, it misses the case for OASOP expression, causing the static init mis-recognizes the modification and think it's safe. Fixing this by adding missing OASOP case. Fixes #66585 Change-Id: I603cec018d3b5a09825c14e1f066a0e16f8bde23 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/575216 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02cmd/compile: check ODEREF for safe lhs in assignment during static initCuong Manh Le
For #66585 Change-Id: Iddc407e3ef4c3b6ecf5173963b66b3e65e43c92d Reviewed-on: https://go-review.googlesource.com/c/go/+/575336 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-01cmd/compile: support float min/max instructions on PPC64Paul E. Murphy
This enables efficient use of the builtin min/max function for float64 and float32 types on GOPPC64 >= power9. Extend the assembler to support xsminjdp/xsmaxjdp and use them to implement float min/max. Simplify the VSX xx3 opcode rules to allow FPR arguments, if all arguments are an FPR. Change-Id: I15882a4ce5dc46eba71d683cf1d184dc4236a328 Reviewed-on: https://go-review.googlesource.com/c/go/+/574535 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-03-30Revert "cmd/compile/internal: merge stack slots for selected local auto vars"Cuong Manh Le
This reverts CL 553055. Reason for revert: causes crypto/ecdsa failures on linux ppc64/s390x builders Change-Id: I9266b030693a5b6b1e667a009de89d613755b048 Reviewed-on: https://go-review.googlesource.com/c/go/+/575236 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-29cmd/compile/internal: merge stack slots for selected local auto varsThan McIntosh
Preliminary compiler support for merging/overlapping stack slots of local variables whose access patterns are disjoint. This patch includes changes in AllocFrame to do the actual merging/overlapping based on information returned from a new liveness.MergeLocals helper. The MergeLocals helper identifies candidates by looking for sets of AUTO variables that either A) have the same size and GC shape (if types contain pointers), or B) have the same size (but potentially different types as long as those types have no pointers). Variables must be greater than (3*types.PtrSize) in size to be considered for merging. After forming candidates, MergeLocals collects variables into "can be overlapped" equivalence classes or partitions; this process is driven by an additional liveness analysis pass. Ideally it would be nice to move the existing stackmap liveness pass up before AllocFrame and "widen" it to include merge candidates so that we can do just a single liveness as opposed to two passes, however this may be difficult given that the merge-locals liveness has to take into account writes corresponding to dead stores. This patch also required a change to the way ssa.OpVarDef pseudo-ops are generated; prior to this point they would only be created for variables whose type included pointers; if stack slot merging is enabled then the ssagen code creates OpVarDef ops for all auto vars that are merge candidates. Note that some temporaries created late in the compilation process (e.g. during ssa backend) are difficult to reason about, especially in cases where we take the address of a temp and pass it to the runtime. For the time being we mark most of the vars created post-ssagen as "not a merge candidate". Stack slot merging for locals/autos is enabled by default if "-N" is not in effect, and can be disabled via "-gcflags=-d=mergelocals=0". Fixmes/todos/restrictions: - try lowering size restrictions - re-evaluate the various skips that happen in SSA-created autotmps Fixes #62737. Updates #65532. Updates #65495. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Change-Id: Ibc22e8a76c87e47bc9fafe4959804d9ea923623d Reviewed-on: https://go-review.googlesource.com/c/go/+/553055 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-29Revert "cmd/compile: add missing OINLCAll case in mayModifyPkgVar"Than McIntosh
This reverts CL 575175. Reason for revert: causes crypto/ecdh failures on longtest builders. Change-Id: Ieed326fedf91760ac73095a42ba0237cf969843b Reviewed-on: https://go-review.googlesource.com/c/go/+/575316 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Than McIntosh <thanm@google.com>
2024-03-29cmd/compile: add missing OINLCAll case in mayModifyPkgVarCuong Manh Le
CL 395541 made staticopy safe, stop applying the optimization once seeing an expression that may modify global variables. However, if a call expression was inlined, the analyzer mis-recognizes and think that the expression is safe. For example: var x = 0 var a = f() var b = x are re-written to: var x = 0 var a = ~r0 var b = 0 even though it's not safe because "f()" may modify "x". Fixing this by recognizing OINLCALL and mark the initialization as not safe for staticopy. Fixes #66585 Change-Id: Id930c0b7e74274195f54a498cc4c5a91c4e6d84d Reviewed-on: https://go-review.googlesource.com/c/go/+/575175 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-28cmd/compile: put constants before variables in initialization orderKeith Randall
Fixes #66575 Change-Id: I03f4d4577b88ad0a92b260b2efd0cb9fe5082b2f Reviewed-on: https://go-review.googlesource.com/c/go/+/575075 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-27test: issue16016: use fewer goroutines for gccgoIan Lance Taylor
For https://gcc.gnu.org/PR114453 Change-Id: If41d9fca6288b18ed47b0f21ff224c74ddb34958 Reviewed-on: https://go-review.googlesource.com/c/go/+/574536 Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-26all: fix a large number of commentscui fliter
Partial typo corrections, following https://go.dev/wiki/Spelling Change-Id: I2357906ff2ea04305c6357418e4e9556e20375d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/573776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-25runtime: migrate internal/atomic to internal/runtimeAndy Pan
For #65355 Change-Id: I65dd090fb99de9b231af2112c5ccb0eb635db2be Reviewed-on: https://go-review.googlesource.com/c/go/+/560155 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ibrahim Bazoka <ibrahimbazoka729@gmail.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-25test/stress: fix typo in commentguoguangwu
Change-Id: I0f67801ef2d3af65c39a27b8db6ebaa769ff7f92 GitHub-Last-Rev: feb7f79ea519450a054de18e10ffa6284538708b GitHub-Pull-Request: golang/go#66508 Reviewed-on: https://go-review.googlesource.com/c/go/+/574075 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2024-03-25test: put type declaration back inside the functioncui fliter
Because issue #47631 has been fixed, remove TODO. Change-Id: Ic476616729f47485a18a5145bd28c87dd18b4492 Reviewed-on: https://go-review.googlesource.com/c/go/+/573775 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-21cmd/compile,cmd/go,cmd/internal,runtime: remove dynamic checks for atomics ↵Andrey Bokhanko
for ARM64 targets that support LSE Remove dynamic checks for atomic instructions for ARM64 targets that support LSE extension. For #66131 Change-Id: I0ec1b183a3f4ea4c8a537430646e6bc4b4f64271 Reviewed-on: https://go-review.googlesource.com/c/go/+/569536 Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Shu-Chun Weng <scw@google.com>
2024-03-21cmd/compile: include constant bools in memcombineKeith Randall
Constant bools are like constant 1-byte values, they memcombine just fine. (There are still trickier cases that this pass doesn't catch yet, see TODO at memcombine.go:503.) Fixes #66413 Change-Id: Ia67cf72ed1c416e27ac22da443bd88a3f09a6cc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/573416 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
2024-03-20cmd/compile: don't assume args are always zero-extendedKeith Randall
On amd64, we always zero-extend when loading arguments from the stack. On arm64, we extend based on the type. This causes problems with zeroUpper*Bits, which reports the top bits are zero when they aren't. Fix it to use the type to decide if the top bits are really zero. For tests, only f32 currently fails on arm64. Added other tests just for future-proofing. Update #66066 Change-Id: I2f13fb47198e139ef13c9a34eb1edc932eea3ee3 Reviewed-on: https://go-review.googlesource.com/c/go/+/571135 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-18go/types, types2: quote user-supplied names in error messagesRobert Griesemer
Use `' quotes (as in `foo') to differentiate from Go quotes. Quoting prevents confusion when user-supplied names alter the meaning of the error message. For instance, report duplicate method `wanted' rather than duplicate method wanted Exceptions: - don't quote _: `_' is ugly and not necessary - don't quote after a ":": undefined name: foo - don't quote if the name is used correctly in a statement: goto L jumps over variable declaration Quoting is done with a helper function and can be centrally adjusted and fine-tuned as needed. Adjusted some test cases to explicitly include the quoted names. Fixes #65790. Change-Id: Icce667215f303ab8685d3e5cb00d540a2fd372ca Reviewed-on: https://go-review.googlesource.com/c/go/+/571396 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Griesemer <gri@google.com>
2024-03-15cmd/compile/internal: generate ADDZE on PPC64Paul E. Murphy
This usage shows up in quite a few places, and helps reduce register pressure in several complex cryto functions by removing a MOVD $0,... instruction. Change-Id: I9444ea8f9d19bfd68fb71ea8dc34e109681b3802 Reviewed-on: https://go-review.googlesource.com/c/go/+/571055 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Paul Murphy <murp@ibm.com>
2024-03-14test/fixedbugs: add regress test for inlining failureMatthew Dempsky
Still investigating, but adding the minimized reproducer as a regress test case for now. Updates #66261. Change-Id: I20715b731f8c5b95616513d4a13e3ae083709031 Reviewed-on: https://go-review.googlesource.com/c/go/+/571815 Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-13cmd/asm,cmd/compile: generate less instructions for most 32 bit constant ↵Paul E. Murphy
adds on ppc64x For GOPPC64 < 10 targets, most large 32 bit constants (those exceeding int16 capacity) can be added using two instructions instead of 3. This cannot be done for values greater than 0x7FFF7FFF, so this must be done during asm preprocessing as the optab matching rules cannot differentiate this special case. Likewise, constants 0x8000 <= x < 0x10000 are not converted. The assembler currently generates 2 instructions sequences for these constants. Change-Id: I1ccc839c6c28fc32f15d286b2e52e2d22a2a06d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/568116 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2024-03-12cmd/compile: fix sign/zero-extension removalKeith Randall
When an opcode generates a known high bit state (typically, a sub-word operation that zeros the high bits), we can remove any subsequent extension operation that would be a no-op. x = (OP ...) y = (ZeroExt32to64 x) If OP zeros the high 32 bits, then we can replace y with x, as the zero extension doesn't do anything. However, x in this situation normally has a sub-word-sized type. The semantics of values in registers is typically that the high bits beyond the value's type size are junk. So although the opcode generating x *currently* zeros the high bits, after x is rewritten to another opcode it may not - rewrites of sub-word-sized values can trash the high bits. To fix, move the extension-removing rules to late lower. That ensures that their arguments won't be rewritten to change their high bits. I am also worried about spilling and restoring. Spilling and restoring doesn't preserve the high bits, but instead sets them to a known value (often 0, but in some cases it could be sign-extended). I am unable to come up with a case that would cause a problem here, so leaving for another time. Fixes #66066 Change-Id: I3b5c091b3b3278ccbb7f11beda8b56f4b6d3fde7 Reviewed-on: https://go-review.googlesource.com/c/go/+/568616 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08cmd/compile: fix copying SSA-able variables optimizationCuong Manh Le
CL 541715 added an optimization to copy SSA-able variables. When handling m[k] = append(m[k], ...) case, it uses ir.SameSafeExpr to check that m[k] expressions are the same, then doing type assertion to convert the map index to ir.IndexExpr node. However, this assertion is not safe for m[k] expression in append(m[k], ...), since it may be wrapped by ir.OCONVNOP node. Fixing this by un-wrapping any ir.OCONVNOP before doing type assertion. Fixes #66096 Change-Id: I9ff7165ab97bc7f88d0e9b7b31604da19a8ca206 Reviewed-on: https://go-review.googlesource.com/c/go/+/569716 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-07cmd/compile,cmd/internal/obj: provide rotation pseudo-instructions for riscv64Joel Sing
Provide and use rotation pseudo-instructions for riscv64. The RISC-V bitmanip extension adds support for hardware rotation instructions in the form of ROL, ROLW, ROR, RORI, RORIW and RORW. These are easily implemented in the assembler as pseudo-instructions for CPUs that do not support the bitmanip extension. This approach provides a number of advantages, including reducing the rewrite rules needed in the compiler, simplifying codegen tests and most importantly, allowing these instructions to be used in assembly (for example, riscv64 optimised versions of SHA-256 and SHA-512). When bitmanip support is added, these instruction sequences can simply be replaced with a single instruction if permitted by the GORISCV64 profile. Change-Id: Ia23402e1a82f211ac760690deb063386056ae1fa Reviewed-on: https://go-review.googlesource.com/c/go/+/565015 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: M Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Joel Sing <joel@sing.id.au>
2024-03-02cmd/compile: add 0-sized-value simplification to copyelimDavid Chase
The problem was caused by faulty handling of unSSA-able operations on zero-sized data in expand calls, but there is no point to operations on zero-sized data. This CL adds a simplify step to the first place in SSA where all values are processed and replaces anything producing a 0-sized struct/array with the corresponding Struct/Array Make0 operation (of the appropriate type). I attempted not generating them in ssagen, but that was a larger change, and also had bugs. This is simple and obvious. The only question is whether it would be worthwhile to do it earlier (in numberlines or phielem). Fixes #65808. Change-Id: I0a596b3d272798015e7bb6b1a20411241759fe0e Reviewed-on: https://go-review.googlesource.com/c/go/+/568258 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-01cmd/compile: add missing Unalias call when writing type aliasCuong Manh Le
Fixes #65778 Change-Id: I93af42967c7976d63b4f460b7ffbcb9a9c05ffe7 Reviewed-on: https://go-review.googlesource.com/c/go/+/565995 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2024-02-29cmd/compile: soften type matching when allocating stack slotskhr@golang.org
Currently we use pointer equality on types when deciding whether we can reuse a stack slot. That's too strict, as we don't guarantee pointer equality for the same type. In particular, it can vary based on whether PtrTo has been called in the frontend or not. Instead, use the type's LinkString, which is guaranteed to both be unique for a type, and to not vary given two different type structures describing the same type. Update #65783 Change-Id: I64f55138475f04bfa30cfb819b786b7cc06aebe4 Reviewed-on: https://go-review.googlesource.com/c/go/+/565436 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2024-02-29runtime: don't re-initialize itab while looking for missing functionkhr@golang.org
The itab we're initializing again, just to figure out which method is missing, might be stored in read-only memory. This can only happen in certain weird generics situations, so it is pretty rare, but it causes a runtime crash when it does happen. Fixes #65962 Change-Id: Ia86e216fe33950a794ad8e475e76317f799e9136 Reviewed-on: https://go-review.googlesource.com/c/go/+/567615 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2024-02-28cmd/compile: mark pointer to noalg type as noalgzuojunwei.1024
When the compiler writes PtrToThis field of noalg type, it generates its pointer type. Mark them as noalg to prevent put them in typelinks. Fixes #65957 Change-Id: Icbc3b18bc866f9138c7648e42dd500a80326f72b Reviewed-on: https://go-review.googlesource.com/c/go/+/567335 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2024-02-28go/types, types2: consistently use singular when reporting version errorsRobert Griesemer
Change-Id: I39af932b789cd18dc4bfc84f9667b1c32c9825f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/567476 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-27cmd/compile: fix early deadcode with label statementCuong Manh Le
CL 517775 moved early deadcode into unified writer. with new way to handle dead code with label statement involved: any statements after terminating statement will be considered dead until next label statement. However, this is not safe, because code after label statement may still refer to dead statements between terminating and label statement. It's only safe to remove statements after terminating *and* label one. Fixes #65593 Change-Id: Idb630165240931fad50789304a9e4535f51f56e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/565596 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2024-02-27cmd/compile: use quotes to wrap user-supplied tokenZxilly
Use quotes to wrap user-supplied token in the syntax error message. Updates #65790 Change-Id: I631a63df4a6bb8615b7850a324d812190bc15f30 GitHub-Last-Rev: f291e1d5a6adee558d21bb7e0a3a17471bad7eb6 GitHub-Pull-Request: golang/go#65840 Reviewed-on: https://go-review.googlesource.com/c/go/+/565518 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-20cmd/compile/internal/typecheck: remove constant bounds checkCuong Manh Le
types2 handles all constant-related bounds checks in user Go code now, so it's safe to remove the check from typecheck, avoid the inconsistency with type parameter. Fixes #65417 Change-Id: I82dd197b78e271725d132b5a20450ae3e90f9abc Reviewed-on: https://go-review.googlesource.com/c/go/+/560575 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-16cmd/compile: improve rotations for riscv64Joel Sing
Enable canRotate for riscv64, enable rotation intrinsics and provide better rewrite implementations for rotations. By avoiding Lsh*x64 and Rsh*Ux64 we can produce better code, especially for 32 and 64 bit rotations. By enabling canRotate we also benefit from the generic rotation rewrite rules. Benchmark on a StarFive VisionFive 2: │ rotate.1 │ rotate.2 │ │ sec/op │ sec/op vs base │ RotateLeft-4 14.700n ± 0% 8.016n ± 0% -45.47% (p=0.000 n=10) RotateLeft8-4 14.70n ± 0% 10.69n ± 0% -27.28% (p=0.000 n=10) RotateLeft16-4 14.70n ± 0% 12.02n ± 0% -18.23% (p=0.000 n=10) RotateLeft32-4 13.360n ± 0% 8.016n ± 0% -40.00% (p=0.000 n=10) RotateLeft64-4 13.360n ± 0% 8.016n ± 0% -40.00% (p=0.000 n=10) geomean 14.15n 9.208n -34.92% Change-Id: I1a2036fdc57cf88ebb6617eb8d92e1d187e183b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/560315 Reviewed-by: M Zhuo <mengzhuo1203@gmail.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2024-02-09cmd/compile: separate inline cost analysis from applying inliningMatthew Dempsky
This CL separates the pass that computes inlinability from the pass that performs inlinability. In particular, the latter can now happen in any flat order, rather than bottom-up order. This also allows inlining of calls exposed by devirtualization. Change-Id: I389c0665fdc8288a6e25129a6744bfb1ace1eff7 Reviewed-on: https://go-review.googlesource.com/c/go/+/562319 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-02-08test/codegen: add float max/min codegen testMeng Zhuo
As CL 514596 and CL 514775 adds hardware implement of float max/min, we should add codegen test for these two CL. Change-Id: I347331032fe9f67a2e6fdb5d3cfe20203296b81c Reviewed-on: https://go-review.googlesource.com/c/go/+/561295 Reviewed-by: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: M Zhuo <mengzhuo1203@gmail.com> Reviewed-by: David Chase <drchase@google.com>
2024-02-07go/types, types2: better errors for non-existing fields or methodsRobert Griesemer
This CL improves the error messages reported when a field or method name is used that doesn't exist. It brings the error messges on par (or better) with the respective errors reported before Go 1.18 (i.e. before switching to the new type checker): Make case distinctions based on whether a field/method is exported and how it is spelled. Factor out that logic into a new function (lookupError) in a new file (errsupport.go), which is generated for go/types. Use lookupError when reporting selector lookup errors and missing struct field keys. Add a comprehensive set of tests (lookup2.go) and spot tests for the two cases brought up by the issue at hand. Adjusted existing tests as needed. Fixes #49736. Change-Id: I2f439948dcd12f9bd1a258367862d8ff96e32305 Reviewed-on: https://go-review.googlesource.com/c/go/+/560055 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2024-01-26go/types, types2: use existing case-insensitive lookup (remove TODO)Robert Griesemer
Rather than implementing a new, less complete mechanism to check if a selector exists with different capitalization, use the existing mechanism in lookupFieldOrMethodImpl by making it available for internal use. Pass foldCase parameter all the way trough to Object.sameId and thus make it consistently available where Object.sameId is used. From sameId, factor out samePkg functionality into stand-alone predicate. Do better case distinction when reporting an error for an undefined selector expression. Cleanup. Change-Id: I7be3cecb4976a4dce3264c7e0c49a320c87101e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/558315 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>