From: Josh Bleecher Snyder Date: Sat, 5 Mar 2016 02:55:09 +0000 (-0800) Subject: cmd/compile: soup up isSamePtr X-Git-Tag: go1.7beta1~1521 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6ed10382f7c81369e69f6c9e406f1df325a85984;p=gostls13.git cmd/compile: soup up isSamePtr This increases the number of matches in make.bash from 853 to 984. Change-Id: I12697697a50ecd86d49698200144a4c80dd3e5a4 Reviewed-on: https://go-review.googlesource.com/20274 Reviewed-by: Todd Neal --- diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 86f3c2010e..356b375657 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -207,11 +207,20 @@ 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 && - p1.Aux == p2.Aux && p1.AuxInt == p2.AuxInt && - p1.Args[0] == p2.Args[0] + if p1.Op != p2.Op { + return false + } + switch p1.Op { + case OpOffPtr: + return p1.AuxInt == p2.AuxInt && isSamePtr(p1.Args[0], p2.Args[0]) + case OpAddr: + // OpAddr's 0th arg is either OpSP or OpSB, which means that it is uniquely identified by its Op. + // Checking for value equality only works after [z]cse has run. + return p1.Aux == p2.Aux && p1.Args[0].Op == p2.Args[0].Op + case OpAddPtr: + return p1.Args[1] == p2.Args[1] && isSamePtr(p1.Args[0], p2.Args[0]) + } + return false } // DUFFZERO consists of repeated blocks of 4 MOVUPSs + ADD,