cmd/compile: make ReassignOracle StaticValue unwrap parens

Teach ReassignOracle.StaticValue to peel OPAREN nodes, matching the
package-level ir.StaticValue helper.

This is a small parity step needed before more callers can switch from
ir.StaticValue to ReassignOracle.StaticValue.

Passes toolstash -cmp.

compilebench results (this CL vs parent):

                         │  parent.txt  │             commit.txt             │
                         │    sec/op    │    sec/op     vs base              │
Template                   154.2m ±  5%   153.6m ±  5%       ~ (p=0.485 n=6)
Unicode                    114.7m ±  2%   117.2m ±  4%       ~ (p=0.310 n=6)
GoTypes                    897.8m ±  2%   878.8m ±  5%       ~ (p=0.310 n=6)
Compiler                   160.2m ± 22%   159.0m ±  6%       ~ (p=0.310 n=6)
SSA                         7.171 ±  4%    7.136 ±  1%       ~ (p=0.485 n=6)
Flate                      171.2m ± 11%   161.8m ±  5%       ~ (p=0.065 n=6)
GoParser                   172.5m ±  6%   172.9m ± 18%       ~ (p=0.589 n=6)
Reflect                    398.9m ± 11%   391.8m ± 13%       ~ (p=0.394 n=6)
Tar                        173.2m ±  4%   168.8m ±  3%       ~ (p=0.093 n=6)
XML                        201.6m ± 23%   194.2m ±  3%       ~ (p=0.240 n=6)
LinkCompiler               639.2m ±  3%   646.7m ±  4%       ~ (p=0.937 n=6)
ExternalLinkCompiler        2.204 ±  2%    2.196 ±  2%       ~ (p=0.699 n=6)
LinkWithoutDebugCompiler   423.5m ±  4%   415.7m ± 13%       ~ (p=0.937 n=6)
StdCmd                      29.73 ±  3%    29.41 ±  2%       ~ (p=0.589 n=6)
geomean                    528.6m         522.2m        -1.22%

                         │  parent.txt  │             commit.txt             │
                         │ user-sec/op  │ user-sec/op   vs base              │
Template                   685.3m ±  8%   746.5m ± 16%       ~ (p=0.132 n=6)
Unicode                    158.6m ±  5%   156.5m ±  9%       ~ (p=0.589 n=6)
GoTypes                     5.001 ±  2%    4.900 ±  1%  -2.01% (p=0.009 n=6)
Compiler                   511.1m ±  4%   500.2m ±  9%       ~ (p=0.699 n=6)
SSA                         37.50 ±  3%    37.34 ±  1%       ~ (p=0.394 n=6)
Flate                      793.4m ± 10%   735.2m ±  8%       ~ (p=0.180 n=6)
GoParser                   698.0m ±  4%   696.3m ±  8%       ~ (p=0.818 n=6)
Reflect                     1.895 ±  5%    1.897 ±  2%       ~ (p=0.937 n=6)
Tar                        794.7m ± 13%   764.9m ± 10%       ~ (p=0.394 n=6)
XML                        936.5m ± 19%   865.7m ±  5%  -7.57% (p=0.009 n=6)
LinkCompiler                1.054 ±  7%    1.077 ±  8%       ~ (p=0.485 n=6)
ExternalLinkCompiler        2.498 ±  2%    2.515 ±  3%       ~ (p=0.937 n=6)
LinkWithoutDebugCompiler   485.8m ±  5%   482.1m ± 14%       ~ (p=1.000 n=6)
geomean                     1.197          1.184        -1.13%

          │  parent.txt  │              commit.txt              │
          │  text-bytes  │  text-bytes   vs base                │
HelloSize   1.110Mi ± 0%   1.110Mi ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   14.14Mi ± 0%   14.14Mi ± 0%       ~ (p=1.000 n=6) ¹
geomean     3.961Mi        3.961Mi       +0.00%
¹ all samples are equal

          │  parent.txt  │              commit.txt              │
          │  data-bytes  │  data-bytes   vs base                │
HelloSize   27.49Ki ± 0%   27.49Ki ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   431.4Ki ± 0%   431.4Ki ± 0%       ~ (p=1.000 n=6) ¹
geomean     108.9Ki        108.9Ki       +0.00%
¹ all samples are equal

          │  parent.txt  │              commit.txt              │
          │  bss-bytes   │  bss-bytes    vs base                │
HelloSize   213.9Ki ± 0%   213.9Ki ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   32.27Mi ± 0%   32.27Mi ± 0%       ~ (p=1.000 n=6) ¹
geomean     2.597Mi        2.597Mi       +0.00%
¹ all samples are equal

          │  parent.txt  │              commit.txt              │
          │  exe-bytes   │  exe-bytes    vs base                │
HelloSize   1.777Mi ± 0%   1.777Mi ± 0%       ~ (p=1.000 n=6) ¹
CmdGoSize   21.29Mi ± 0%   21.29Mi ± 0%       ~ (p=1.000 n=6) ¹
geomean     6.150Mi        6.150Mi       +0.00%
¹ all samples are equal

Change-Id: I31c77871939a057415d2b99b051b28624f88e9d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/778800
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Jake Bailey 2026-05-16 23:36:36 -07:00 committed by Keith Randall
parent 1bcfdf2df2
commit 2f0459745c

View file

@ -172,6 +172,11 @@ func (ro *ReassignOracle) StaticValue(n Node) Node {
continue
}
if n.Op() == OPAREN {
n = n.(*ParenExpr).X
continue
}
n1 := ro.staticValue1(n)
if n1 == nil {
if consistencyCheckEnabled {