]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove pointer temporaries in walkcompare
authorMatthew Dempsky <mdempsky@google.com>
Thu, 26 Sep 2019 18:00:13 +0000 (11:00 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 30 Sep 2019 23:44:36 +0000 (23:44 +0000)
When comparing two T-typed values t1 and t2 using the T_eq function,
we used to generate:

    pl := &t1
    pr := &t2
    return T_eq(pl, pr, unsafe.Sizeof(T{}))

This CL changes it to simply generate:

    return T_eq(&t1, &t2, unsafe.Sizeof(T{}))

Surprisingly, this does not pass toolstash. For some reason, it seems
like SSA wasn't able to SSA-ify the pl and pr variables in all cases.

Change-Id: I111fbb068a1741fa169c9922cb8cdb6e21579aa4
Reviewed-on: https://go-review.googlesource.com/c/go/+/197601
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/walk.go

index e19b6329bad4adc7e7224e538b0bf1c0a5b5eaff..727c8102ae58cd5cce92d1e3c1f94f8f5ae75575 100644 (file)
@@ -3130,20 +3130,10 @@ func walkcompare(n *Node, init *Nodes) *Node {
                        Fatalf("arguments of comparison must be lvalues - %v %v", cmpl, cmpr)
                }
 
-               pl := temp(types.NewPtr(t))
-               al := nod(OAS, pl, nod(OADDR, cmpl, nil))
-               al = typecheck(al, ctxStmt)
-               init.Append(al)
-
-               pr := temp(types.NewPtr(t))
-               ar := nod(OAS, pr, nod(OADDR, cmpr, nil))
-               ar = typecheck(ar, ctxStmt)
-               init.Append(ar)
-
                fn, needsize := eqfor(t)
                call := nod(OCALL, fn, nil)
-               call.List.Append(pl)
-               call.List.Append(pr)
+               call.List.Append(nod(OADDR, cmpl, nil))
+               call.List.Append(nod(OADDR, cmpr, nil))
                if needsize {
                        call.List.Append(nodintconst(t.Width))
                }