cmd/compile: handle OCONV[NOP] in samesafeexpr

This increases the effectiveness of the
"integer-in-range" CL that follows.

Change-Id: I23b7b6809f0b2c25ed1d59dd2d5429c30f1db89c
Reviewed-on: https://go-review.googlesource.com/27651
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-06-01 11:07:05 -07:00
parent 507051d694
commit 9d4623fe43
1 changed files with 6 additions and 1 deletions

View File

@ -3186,9 +3186,14 @@ func samesafeexpr(l *Node, r *Node) bool {
case ODOT, ODOTPTR:
return l.Sym != nil && r.Sym != nil && l.Sym == r.Sym && samesafeexpr(l.Left, r.Left)
case OIND:
case OIND, OCONVNOP:
return samesafeexpr(l.Left, r.Left)
case OCONV:
// Some conversions can't be reused, such as []byte(str).
// Allow only numeric-ish types. This is a bit conservative.
return issimple[l.Type.Etype] && samesafeexpr(l.Left, r.Left)
case OINDEX:
return samesafeexpr(l.Left, r.Left) && samesafeexpr(l.Right, r.Right)