This is the 386 version of the amd64-specific https://golang.org/cl/16933.
Update #12416.
Change-Id: Ibc3a99dcc753d6281839d8b61016d6c21dbd9649
Reviewed-on: https://go-review.googlesource.com/16970
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
 
        // General case.
        var r1, r2, g1, g2 gc.Node
-       if n1.Op == gc.ONAME && n1.Class&gc.PHEAP == 0 || n1.Op == gc.OINDREG {
+
+       // A special case to make write barriers more efficient.
+       // Comparing the first field of a named struct can be done directly.
+       base := n1
+       if n1.Op == gc.ODOT && n1.Left.Type.Etype == gc.TSTRUCT && n1.Left.Type.Type.Sym == n1.Right.Sym {
+               base = n1.Left
+       }
+
+       if base.Op == gc.ONAME && base.Class&gc.PHEAP == 0 || n1.Op == gc.OINDREG {
                r1 = *n1
        } else {
                gc.Regalloc(&r1, t, n1)