mirror of
https://github.com/golang/go
synced 2024-11-19 13:14:42 -07:00
cmd/compile: collapse OffPtr sequences
This triggers an astonishing 160k times during make.bash. The second biggest generic rewrite triggers 100k times. However, this is really just moving rewrites that were happening at the architecture level to the generic level. Change-Id: Ife06fe5234f31433328460cb2e0741c071deda41 Reviewed-on: https://go-review.googlesource.com/20235 Run-TryBot: Todd Neal <todd@tneal.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Todd Neal <todd@tneal.org>
This commit is contained in:
parent
12e60452e9
commit
3294014ae1
@ -404,6 +404,9 @@
|
|||||||
// Load of store of same address, with compatibly typed value and same size
|
// Load of store of same address, with compatibly typed value and same size
|
||||||
(Load <t1> p1 (Store [w] p2 x _)) && isSamePtr(p1,p2) && t1.Compare(x.Type)==CMPeq && w == t1.Size() -> x
|
(Load <t1> p1 (Store [w] p2 x _)) && isSamePtr(p1,p2) && t1.Compare(x.Type)==CMPeq && w == t1.Size() -> x
|
||||||
|
|
||||||
|
// Collapse OffPtr
|
||||||
|
(OffPtr (OffPtr p [b]) [a]) -> (OffPtr p [a+b])
|
||||||
|
|
||||||
|
|
||||||
// indexing operations
|
// indexing operations
|
||||||
// Note: bounds check has already been done
|
// Note: bounds check has already been done
|
||||||
|
@ -206,6 +206,8 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
|||||||
return rewriteValuegeneric_OpNeqPtr(v, config)
|
return rewriteValuegeneric_OpNeqPtr(v, config)
|
||||||
case OpNeqSlice:
|
case OpNeqSlice:
|
||||||
return rewriteValuegeneric_OpNeqSlice(v, config)
|
return rewriteValuegeneric_OpNeqSlice(v, config)
|
||||||
|
case OpOffPtr:
|
||||||
|
return rewriteValuegeneric_OpOffPtr(v, config)
|
||||||
case OpOr16:
|
case OpOr16:
|
||||||
return rewriteValuegeneric_OpOr16(v, config)
|
return rewriteValuegeneric_OpOr16(v, config)
|
||||||
case OpOr32:
|
case OpOr32:
|
||||||
@ -4821,6 +4823,26 @@ func rewriteValuegeneric_OpNeqSlice(v *Value, config *Config) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
func rewriteValuegeneric_OpOffPtr(v *Value, config *Config) bool {
|
||||||
|
b := v.Block
|
||||||
|
_ = b
|
||||||
|
// match: (OffPtr (OffPtr p [b]) [a])
|
||||||
|
// cond:
|
||||||
|
// result: (OffPtr p [a+b])
|
||||||
|
for {
|
||||||
|
if v.Args[0].Op != OpOffPtr {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
p := v.Args[0].Args[0]
|
||||||
|
b := v.Args[0].AuxInt
|
||||||
|
a := v.AuxInt
|
||||||
|
v.reset(OpOffPtr)
|
||||||
|
v.AddArg(p)
|
||||||
|
v.AuxInt = a + b
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
func rewriteValuegeneric_OpOr16(v *Value, config *Config) bool {
|
func rewriteValuegeneric_OpOr16(v *Value, config *Config) bool {
|
||||||
b := v.Block
|
b := v.Block
|
||||||
_ = b
|
_ = b
|
||||||
|
Loading…
Reference in New Issue
Block a user