From: Keith Randall Date: Wed, 24 Feb 2016 20:58:47 +0000 (-0800) Subject: [dev.ssa] cmd/compile: identical values are the same pointer X-Git-Tag: go1.7beta1~1623^2^2~21 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a5325761cd42f2a10566fd421f8c8b0189bedc18;p=gostls13.git [dev.ssa] cmd/compile: identical values are the same pointer Forgot the obvious case. Allows us to remove the load in: func f(p *int, x int) int { *p = x + 5 return *p } Change-Id: I93686d8240bab3a1d166b88e224cf71e3d947aef Reviewed-on: https://go-review.googlesource.com/19905 Run-TryBot: Keith Randall Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 4197b0da88..60509d214e 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -204,6 +204,9 @@ func uaddOvf(a, b int64) bool { // isSamePtr reports whether p1 and p2 point to the same address. func isSamePtr(p1, p2 *Value) bool { + if p1 == p2 { + return true + } // Aux isn't used in OffPtr, and AuxInt isn't currently used in // Addr, but this still works as the values will be null/0 return (p1.Op == OpOffPtr || p1.Op == OpAddr) && p1.Op == p2.Op &&