mirror of
https://github.com/golang/go
synced 2024-11-24 16:50:13 -07:00
[dev.ssa] cmd/compile/internal/ssa: simplify convert in more cases
Saves about 2k for binaries in pkg/tool/linux_amd64. Also useful when opt runs after cse (as in 12960) which reorders arguments for commutative operations such as Add64. Change-Id: I49ad53afa53db9736bd35c425f4fb35fb511fd63 Reviewed-on: https://go-review.googlesource.com/19827 Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
80bc512449
commit
d337e55672
@ -586,6 +586,7 @@
|
||||
|
||||
// Get rid of Convert ops for pointer arithmetic on unsafe.Pointer.
|
||||
(Convert (Add64 (Convert ptr mem) off) mem) -> (Add64 ptr off)
|
||||
(Convert (Add64 off (Convert ptr mem)) mem) -> (Add64 ptr off)
|
||||
(Convert (Convert ptr mem) mem) -> ptr
|
||||
|
||||
// Decompose compound argument values
|
||||
|
@ -1428,6 +1428,27 @@ func rewriteValuegeneric_OpConvert(v *Value, config *Config) bool {
|
||||
v.AddArg(off)
|
||||
return true
|
||||
}
|
||||
// match: (Convert (Add64 off (Convert ptr mem)) mem)
|
||||
// cond:
|
||||
// result: (Add64 ptr off)
|
||||
for {
|
||||
if v.Args[0].Op != OpAdd64 {
|
||||
break
|
||||
}
|
||||
off := v.Args[0].Args[0]
|
||||
if v.Args[0].Args[1].Op != OpConvert {
|
||||
break
|
||||
}
|
||||
ptr := v.Args[0].Args[1].Args[0]
|
||||
mem := v.Args[0].Args[1].Args[1]
|
||||
if v.Args[1] != mem {
|
||||
break
|
||||
}
|
||||
v.reset(OpAdd64)
|
||||
v.AddArg(ptr)
|
||||
v.AddArg(off)
|
||||
return true
|
||||
}
|
||||
// match: (Convert (Convert ptr mem) mem)
|
||||
// cond:
|
||||
// result: ptr
|
||||
|
Loading…
Reference in New Issue
Block a user