1
0
mirror of https://github.com/golang/go synced 2024-11-24 18:50:05 -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:
Alexandru Moșoi 2016-02-23 21:48:33 +01:00 committed by Alexandru Moșoi
parent 80bc512449
commit d337e55672
2 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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