1
0
mirror of https://github.com/golang/go synced 2024-11-19 12:04:43 -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:
Josh Bleecher Snyder 2016-03-04 14:12:44 -08:00
parent 12e60452e9
commit 3294014ae1
2 changed files with 25 additions and 0 deletions

View File

@ -404,6 +404,9 @@
// 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
// Collapse OffPtr
(OffPtr (OffPtr p [b]) [a]) -> (OffPtr p [a+b])
// indexing operations
// Note: bounds check has already been done

View File

@ -206,6 +206,8 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
return rewriteValuegeneric_OpNeqPtr(v, config)
case OpNeqSlice:
return rewriteValuegeneric_OpNeqSlice(v, config)
case OpOffPtr:
return rewriteValuegeneric_OpOffPtr(v, config)
case OpOr16:
return rewriteValuegeneric_OpOr16(v, config)
case OpOr32:
@ -4821,6 +4823,26 @@ func rewriteValuegeneric_OpNeqSlice(v *Value, config *Config) bool {
}
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 {
b := v.Block
_ = b