mirror of https://github.com/golang/go.git
[dev.ssa] cmd/compile: get rid of converts in unsafe.Pointer arithmetic
unsafe.Pointer->uintptr, add, then uintptr->unsafe.Pointer. Do the add directly on the pointer type instead. Change-Id: I5a3a32691d0a000e16975857974ed9a1039c6d28 Reviewed-on: https://go-review.googlesource.com/16281 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
e99dd52066
commit
a3180d8b1d
|
|
@ -185,3 +185,6 @@
|
|||
(If (Not cond) yes no) -> (If cond no yes)
|
||||
(If (ConstBool [c]) yes no) && c == 1 -> (First nil yes no)
|
||||
(If (ConstBool [c]) yes no) && c == 0 -> (First nil no yes)
|
||||
|
||||
// Get rid of Convert ops for pointer arithmetic on unsafe.Pointer.
|
||||
(Convert (Add64 (Convert ptr) off)) -> (Add64 ptr off)
|
||||
|
|
|
|||
|
|
@ -354,6 +354,30 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
|||
goto end2eb756398dd4c6b6d126012a26284c89
|
||||
end2eb756398dd4c6b6d126012a26284c89:
|
||||
;
|
||||
case OpConvert:
|
||||
// match: (Convert (Add64 (Convert ptr) off))
|
||||
// cond:
|
||||
// result: (Add64 ptr off)
|
||||
{
|
||||
if v.Args[0].Op != OpAdd64 {
|
||||
goto end913a7ecf456c00ffbee36c2dbbf0e1af
|
||||
}
|
||||
if v.Args[0].Args[0].Op != OpConvert {
|
||||
goto end913a7ecf456c00ffbee36c2dbbf0e1af
|
||||
}
|
||||
ptr := v.Args[0].Args[0].Args[0]
|
||||
off := v.Args[0].Args[1]
|
||||
v.Op = OpAdd64
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v.AddArg(ptr)
|
||||
v.AddArg(off)
|
||||
return true
|
||||
}
|
||||
goto end913a7ecf456c00ffbee36c2dbbf0e1af
|
||||
end913a7ecf456c00ffbee36c2dbbf0e1af:
|
||||
;
|
||||
case OpEq16:
|
||||
// match: (Eq16 x x)
|
||||
// cond:
|
||||
|
|
|
|||
Loading…
Reference in New Issue