]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow named values on RHS of rewrite rules
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Apr 2020 07:30:14 +0000 (00:30 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 23 Apr 2020 19:39:12 +0000 (19:39 +0000)
Fixes #38621

Change-Id: Idbffdcc70903290dc58e5abb4867718bd5449fe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229701
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/rulegen.go

index 0c8ba65e7e6a6d5cddf5b497901b75401402be18..c5728606bf74ba4bb6faa5a367a52ea7f46e3da1 100644 (file)
@@ -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 {