From: Josh Bleecher Snyder Date: Thu, 23 Apr 2020 07:30:14 +0000 (-0700) Subject: cmd/compile: allow named values on RHS of rewrite rules X-Git-Tag: go1.15beta1~418 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d9d88dd27f31936e11dfa621937f09db9a23af36;p=gostls13.git cmd/compile: allow named values on RHS of rewrite rules Fixes #38621 Change-Id: Idbffdcc70903290dc58e5abb4867718bd5449fe1 Reviewed-on: https://go-review.googlesource.com/c/go/+/229701 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go index 0c8ba65e7e..c5728606bf 100644 --- a/src/cmd/compile/internal/ssa/gen/rulegen.go +++ b/src/cmd/compile/internal/ssa/gen/rulegen.go @@ -1194,6 +1194,8 @@ func genResult(rr *RuleRewrite, arch arch, result, pos string) { } func genResult0(rr *RuleRewrite, arch arch, result string, top, move bool, pos string) string { + resname, expr := splitNameExpr(result) + result = expr // TODO: when generating a constant result, use f.constVal to avoid // introducing copies just to clean them up again. if result[0] != '(' { @@ -1225,7 +1227,11 @@ func genResult0(rr *RuleRewrite, arch arch, result string, top, move bool, pos s if typ == "" { log.Fatalf("sub-expression %s (op=Op%s%s) at %s must have a type", result, oparch, op.name, rr.Loc) } - v = fmt.Sprintf("v%d", rr.Alloc) + if resname == "" { + v = fmt.Sprintf("v%d", rr.Alloc) + } else { + v = resname + } rr.Alloc++ rr.add(declf(v, "b.NewValue0(%s, Op%s%s, %s)", pos, oparch, op.name, typ)) if move && top {