mirror of
https://github.com/golang/go.git
synced 2025-11-10 05:31:03 +00:00
cmd/compile: allow noop conversions when comparing expressions
Allows mapclear optimization to trigger in more cases, including some generic instantiations. Fixes #51699 Change-Id: Ic54f7686e5fcb8fbcad640aa77ed326d7338b938 Reviewed-on: https://go-review.googlesource.com/c/go/+/393434 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
ed4db86118
commit
e5e638e512
1 changed files with 6 additions and 5 deletions
|
|
@ -973,6 +973,12 @@ var IsIntrinsicCall = func(*CallExpr) bool { return false }
|
|||
// lvalue expression is for OSLICE and OAPPEND optimizations, and it
|
||||
// is correct in those settings.
|
||||
func SameSafeExpr(l Node, r Node) bool {
|
||||
for l.Op() == OCONVNOP {
|
||||
l = l.(*ConvExpr).X
|
||||
}
|
||||
for r.Op() == OCONVNOP {
|
||||
r = r.(*ConvExpr).X
|
||||
}
|
||||
if l.Op() != r.Op() || !types.Identical(l.Type(), r.Type()) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -996,11 +1002,6 @@ func SameSafeExpr(l Node, r Node) bool {
|
|||
r := r.(*UnaryExpr)
|
||||
return SameSafeExpr(l.X, r.X)
|
||||
|
||||
case OCONVNOP:
|
||||
l := l.(*ConvExpr)
|
||||
r := r.(*ConvExpr)
|
||||
return SameSafeExpr(l.X, r.X)
|
||||
|
||||
case OCONV:
|
||||
l := l.(*ConvExpr)
|
||||
r := r.(*ConvExpr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue