Youlin Feng
c7ccbddf22
cmd/compile/internal/ssa: more aggressive on dead auto elim
...
Propagate "unread" across OpMoves. If the addr of this auto is only used
by an OpMove as its source arg, and the OpMove's target arg is the addr
of another auto. If the 2nd auto can be eliminated, this one can also be
eliminated.
This CL eliminates unnecessary memory copies and makes the frame smaller
in the following code snippet:
func contains(m map[string][16]int, k string) bool {
_, ok := m[k]
return ok
}
These are the benchmark results followed by the benchmark code:
goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Map1Access2Ok-8 9.582n ± 2% 9.226n ± 0% -3.72% (p=0.000 n=20)
Map2Access2Ok-8 13.79n ± 1% 10.24n ± 1% -25.77% (p=0.000 n=20)
Map3Access2Ok-8 68.68n ± 1% 12.65n ± 1% -81.58% (p=0.000 n=20)
package main_test
import "testing"
var (
m1 = map[int]int{}
m2 = map[int][16]int{}
m3 = map[int][256]int{}
)
func init() {
for i := range 1000 {
m1[i] = i
m2[i] = [16]int{15:i}
m3[i] = [256]int{255:i}
}
}
func BenchmarkMap1Access2Ok(b *testing.B) {
for i := range b.N {
_, ok := m1[i%1000]
if !ok {
b.Errorf("%d not found", i)
}
}
}
func BenchmarkMap2Access2Ok(b *testing.B) {
for i := range b.N {
_, ok := m2[i%1000]
if !ok {
b.Errorf("%d not found", i)
}
}
}
func BenchmarkMap3Access2Ok(b *testing.B) {
for i := range b.N {
_, ok := m3[i%1000]
if !ok {
b.Errorf("%d not found", i)
}
}
}
Fixes #75398
Change-Id: If75e9caaa50d460efc31a94565b9ba28c8158771
Reviewed-on: https://go-review.googlesource.com/c/go/+/702875
Reviewed-by: Keith Randall <khr@golang.org >
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com >
Auto-Submit: Keith Randall <khr@golang.org >
Reviewed-by: Keith Randall <khr@google.com >
Reviewed-by: Michael Pratt <mpratt@google.com >
2025-11-04 12:46:15 -08:00
..
2023-10-19 23:33:25 +00:00
2017-01-20 05:55:53 +00:00
2023-06-16 17:08:43 +00:00
2022-01-10 21:27:19 +00:00
2021-07-14 23:33:46 +00:00
2024-11-22 02:04:41 +00:00
2022-03-24 02:14:15 +00:00
2025-11-04 12:46:15 -08:00
2016-05-02 13:43:18 +00:00
2025-10-29 11:00:23 -07:00
2022-09-27 21:10:19 +00:00
2023-03-28 14:28:33 +00:00
2024-09-17 17:01:20 +00:00
2024-07-23 19:05:35 +00:00
2025-10-29 11:00:23 -07:00
2022-03-24 17:50:47 +00:00
2024-06-07 15:22:22 +00:00
2021-12-13 22:42:08 +00:00
2024-03-25 19:21:35 +00:00
2024-11-14 02:14:13 +00:00
2025-10-29 11:00:23 -07:00
2025-10-06 16:01:40 -07:00
2013-01-30 20:21:08 +01:00
2016-04-24 21:36:52 +00:00
2016-05-02 13:43:18 +00:00
2024-10-23 04:43:01 +00:00
2017-01-20 05:55:53 +00:00
2016-05-02 13:43:18 +00:00
2018-04-09 18:57:37 +00:00
2022-09-28 22:28:39 +00:00
2018-05-06 04:28:23 +00:00
2012-11-08 09:04:27 -08:00
2021-10-30 18:30:05 +00:00
2024-11-18 18:52:54 +00:00
2016-03-17 04:20:02 +00:00
2013-02-12 13:17:49 -05:00
2012-05-24 22:41:07 -04:00
2020-12-14 12:13:36 -08:00
2013-10-08 14:36:20 -04:00
2012-09-10 13:03:07 -07:00
2020-10-27 03:11:45 +00:00
2020-12-01 21:49:31 +00:00
2021-01-05 21:44:30 +00:00
2023-10-19 23:33:25 +00:00
2021-03-05 18:46:43 +00:00
2012-02-19 13:19:43 +11:00
2025-10-29 18:49:40 -07:00
2023-01-31 19:43:07 +00:00
2012-02-16 23:48:57 -05:00
2015-01-29 13:07:30 +00:00
2023-03-06 18:34:24 +00:00
2023-10-19 23:33:25 +00:00
2021-01-20 22:53:32 +00:00
2021-01-23 02:15:24 +00:00
2021-02-01 18:28:05 +00:00
2012-07-01 21:59:50 +04:00
2020-12-01 21:49:31 +00:00
2015-06-26 03:38:21 +00:00
2019-03-14 21:00:20 +00:00
2017-03-15 22:45:17 +00:00
2017-03-15 22:45:17 +00:00
2017-03-15 22:45:17 +00:00
2025-03-11 05:44:15 -07:00
2012-02-19 13:19:43 +11:00
2016-05-02 13:43:18 +00:00
2020-12-01 21:49:31 +00:00
2020-12-01 21:49:31 +00:00
2012-02-19 13:19:43 +11:00
2015-07-11 14:36:33 +00:00
2015-07-11 14:36:33 +00:00
2016-05-02 13:43:18 +00:00
2023-04-11 20:56:32 +00:00
2022-06-28 18:11:31 +00:00
2019-09-26 23:54:29 +00:00
2016-05-02 13:43:18 +00:00
2022-09-08 15:55:44 +00:00
2012-02-19 13:19:43 +11:00
2022-09-19 18:58:26 +00:00
2025-10-14 15:09:35 -07:00
2025-10-09 08:23:21 -07:00
2012-02-19 13:19:43 +11:00
2022-11-17 13:46:05 +00:00
2021-03-23 05:11:09 +00:00
2025-03-10 21:30:51 -07:00
2013-02-12 13:17:49 -05:00
2022-09-28 22:28:39 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2013-02-12 13:17:49 -05:00
2021-06-14 07:12:37 +00:00
2013-02-12 13:17:49 -05:00
2024-07-29 14:30:07 +00:00
2021-01-05 21:11:31 +00:00
2019-10-16 00:05:37 +00:00
2025-10-29 11:00:23 -07:00
2021-08-09 16:10:20 +00:00
2025-10-08 14:09:22 -07:00
2025-10-08 14:09:22 -07:00
2025-10-14 09:33:37 -07:00
2022-09-02 06:22:23 +00:00
2022-09-02 06:22:23 +00:00
2016-05-02 13:43:18 +00:00
2021-01-19 20:07:52 +00:00
2021-01-19 20:07:52 +00:00
2012-02-19 14:28:53 +11:00
2023-05-12 12:34:59 +00:00
2025-05-19 16:14:53 -07:00
2025-05-19 16:14:53 -07:00
2024-07-22 21:27:37 +00:00
2025-05-21 12:02:43 -07:00
2025-04-04 15:04:34 -07:00
2025-02-19 13:38:58 -08:00
2025-05-19 16:14:53 -07:00
2024-07-22 21:27:37 +00:00
2020-09-12 08:31:49 +00:00
2021-07-28 21:41:07 +00:00
2019-11-16 20:31:45 +00:00
2025-05-21 12:24:22 -07:00
2025-05-21 12:02:43 -07:00
2020-09-12 08:31:49 +00:00
2019-09-03 17:52:06 +00:00
2025-10-02 11:02:07 -07:00
2025-05-19 16:14:53 -07:00
2023-08-18 11:58:37 +00:00
2021-05-26 23:50:32 +00:00
2024-09-18 20:57:20 +00:00
2024-03-25 19:53:03 +00:00
2019-04-17 16:36:56 +00:00
2025-05-19 16:14:53 -07:00
2020-09-12 08:31:49 +00:00
2020-09-12 08:31:49 +00:00
2021-05-26 23:50:32 +00:00
2019-04-17 19:09:15 +00:00
2025-05-21 20:07:36 -07:00
2022-09-07 17:25:59 +00:00
2023-03-06 18:34:24 +00:00
2014-12-08 22:22:58 +00:00
2023-11-16 05:48:00 +00:00
2016-09-14 16:39:47 +00:00
2021-12-03 16:24:32 +00:00
2013-02-12 13:17:49 -05:00
2013-02-12 13:17:49 -05:00
2023-07-10 16:36:41 +00:00
2020-12-04 21:22:23 +00:00
2012-02-19 14:28:53 +11:00
2024-09-30 22:04:40 +00:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2012-02-19 14:28:53 +11:00
2020-12-04 21:22:23 +00:00
2020-12-04 21:22:23 +00:00
2024-08-07 16:07:55 +00:00
2012-02-19 14:28:53 +11:00
2023-10-19 23:33:25 +00:00
2012-02-19 14:28:53 +11:00
2016-05-02 13:43:18 +00:00
2019-10-10 19:38:06 +00:00
2025-10-29 11:00:23 -07:00
2017-04-19 02:27:58 +00:00
2025-10-09 14:59:40 -07:00
2018-05-31 17:36:45 +00:00
2012-01-18 16:12:24 -08:00
2012-02-23 18:47:26 +11:00
2022-09-27 21:10:19 +00:00
2016-05-02 13:43:18 +00:00
2012-10-07 23:22:01 +02:00
2017-03-24 20:07:15 +00:00
2022-01-11 02:26:58 +00:00
2012-02-23 18:47:26 +11:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2019-09-08 17:28:20 +00:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2016-05-02 13:43:18 +00:00
2020-12-14 12:13:36 -08:00
2012-02-20 07:44:24 +11:00
2022-09-23 20:27:09 +00:00
2022-11-16 04:04:52 +00:00
2022-01-11 02:26:58 +00:00
2024-10-22 22:20:29 +00:00
2023-08-18 11:58:37 +00:00
2019-01-08 21:54:04 +00:00
2019-01-08 21:54:04 +00:00
2025-05-19 16:14:53 -07:00
2017-03-03 21:29:32 +00:00
2023-10-19 23:33:25 +00:00
2025-04-22 08:28:13 -07:00
2025-03-24 11:41:09 -07:00
2021-05-26 23:50:45 +00:00
2025-03-06 10:07:17 -08:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2023-10-19 23:33:25 +00:00
2023-10-19 23:33:25 +00:00
2012-02-23 18:47:26 +11:00
2020-11-28 02:31:54 +00:00
2020-11-28 02:31:54 +00:00
2023-10-19 23:33:25 +00:00
2023-10-19 23:33:25 +00:00
2024-05-15 19:27:25 +00:00
2019-08-28 19:27:20 +00:00
2024-06-07 15:22:22 +00:00
2023-10-19 23:33:25 +00:00
2023-10-19 23:33:25 +00:00
2019-11-01 20:13:05 +00:00
2019-02-19 22:45:09 +00:00
2013-02-12 13:17:49 -05:00
2016-05-02 13:43:18 +00:00
2025-07-30 11:47:14 -07:00
2025-10-09 14:59:40 -07:00
2023-10-19 23:33:25 +00:00
2025-10-09 14:59:40 -07:00
2025-10-03 12:31:36 -07:00
2020-12-17 04:43:46 +00:00
2024-04-04 14:29:45 +00:00
2021-04-23 00:41:01 +00:00
2020-12-04 21:22:23 +00:00
2020-05-07 17:50:24 +00:00
2012-02-23 18:47:26 +11:00
2020-12-14 12:13:36 -08:00
2014-08-06 17:02:55 -04:00
2018-05-08 21:15:16 +00:00
2023-10-19 23:33:25 +00:00
2021-11-05 00:52:06 +00:00
2017-09-03 14:29:38 +00:00
2022-09-27 21:59:19 +00:00
2022-01-10 22:48:40 +00:00
2012-02-23 18:47:26 +11:00
2012-10-07 23:22:01 +02:00
2016-05-02 13:43:18 +00:00
2020-12-04 21:22:23 +00:00
2021-01-26 17:05:06 +00:00
2013-02-11 18:20:52 -05:00
2020-12-04 21:22:23 +00:00
2025-09-26 10:10:03 -07:00
2025-03-06 10:07:17 -08:00
2013-02-12 13:17:49 -05:00
2022-06-30 18:41:59 +00:00
2019-05-11 03:02:33 +00:00
2023-10-19 23:33:25 +00:00
2025-09-19 07:13:32 -07:00
2025-09-19 07:13:32 -07:00
2025-09-19 07:13:32 -07:00
2023-10-19 23:33:25 +00:00
2025-05-12 11:05:28 -07:00
2023-04-14 17:57:36 +00:00
2025-10-07 08:21:14 -07:00
2023-08-22 19:18:21 +00:00
2016-10-25 22:28:40 +00:00
2023-10-19 23:33:25 +00:00
2012-02-24 10:30:39 +11:00
2018-04-30 19:39:18 +00:00
2025-05-08 10:18:37 -07:00
2025-10-29 11:00:23 -07:00
2025-10-30 09:17:59 -07:00
2025-10-29 18:49:40 -07:00
2025-03-11 20:17:36 -07:00
2025-10-30 09:17:59 -07:00
2025-07-29 12:44:58 -07:00
2023-12-01 17:20:08 +00:00
2025-07-29 12:44:58 -07:00
2017-09-12 05:50:54 +00:00
2025-07-29 12:44:58 -07:00
2023-05-12 17:18:08 +00:00
2019-09-03 20:41:29 +00:00
2023-10-19 23:33:25 +00:00
2016-03-11 21:19:20 +00:00
2016-03-11 21:19:20 +00:00
2016-03-11 21:19:20 +00:00
2016-03-11 22:07:02 +00:00
2020-04-19 03:12:32 +00:00
2020-04-19 03:12:32 +00:00
2021-10-26 14:24:17 +00:00
2021-07-22 17:48:41 +00:00
2023-04-19 14:07:00 +00:00
2016-05-02 13:43:18 +00:00
2021-01-16 23:19:26 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2016-05-02 13:43:18 +00:00
2020-12-09 23:56:19 +00:00
2021-12-03 16:24:32 +00:00
2016-05-02 13:43:18 +00:00
2022-04-07 17:19:55 +00:00
2012-02-24 11:48:19 +11:00
2023-10-19 23:33:25 +00:00
2016-05-02 13:43:18 +00:00
2020-12-14 21:28:48 +00:00
2018-03-08 22:25:25 +00:00
2012-02-24 11:48:19 +11:00
2018-06-12 19:10:34 +00:00
2019-09-08 17:28:20 +00:00
2016-05-02 13:43:18 +00:00
2024-11-14 02:14:13 +00:00
2020-12-15 19:43:32 +00:00
2020-12-14 21:28:48 +00:00
2022-09-24 17:04:15 +00:00
2020-12-14 21:28:48 +00:00
2022-07-19 23:30:49 +00:00
2025-06-04 08:27:44 -07:00
2025-02-13 14:07:47 -08:00
2015-11-03 18:57:18 +00:00
2012-02-24 11:48:19 +11:00
2022-01-11 02:26:58 +00:00
2022-09-23 20:27:09 +00:00
2019-09-11 23:33:11 +00:00
2022-09-27 21:10:19 +00:00
2021-11-12 22:20:51 +00:00
2025-10-09 14:59:40 -07:00
2019-11-05 00:26:30 +00:00
2016-07-06 20:48:41 +00:00
2022-04-21 18:06:38 +00:00
2016-05-02 13:43:18 +00:00
2022-08-31 17:15:15 +00:00
2022-08-31 17:15:15 +00:00
2022-08-31 17:15:15 +00:00
2022-08-31 17:15:15 +00:00
2025-09-23 13:12:12 -07:00
2012-02-24 11:48:19 +11:00
2020-12-04 21:22:23 +00:00
2012-02-24 11:48:19 +11:00
2024-11-11 17:11:50 +00:00
2024-08-09 20:07:54 +00:00
2024-10-28 13:27:58 +00:00
2025-02-06 13:16:59 -08:00
2020-12-02 16:33:57 +00:00
2021-08-23 19:46:36 +00:00
2021-10-06 15:53:04 +00:00
2023-04-28 18:35:43 +00:00