Commit 3294014a authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: default avatarTodd Neal <todd@tneal.org>
parent 12e60452
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment