Commit 4b3a55ec authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: add 32 bit (AddPtr (Const)) rule

This triggers about 50k times during 32 bit make.bash.

Change-Id: Ia0c2b1a8246b92173b4b0d94a4037626f76b6e73
Reviewed-on: https://go-review.googlesource.com/37998
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
parent 3dcfce8d
......@@ -98,6 +98,7 @@
(Const32F [f2i(float64(i2f32(c) + i2f32(d)))]) // ensure we combine the operands with 32 bit precision
(Add64F (Const64F [c]) (Const64F [d])) -> (Const64F [f2i(i2f(c) + i2f(d))])
(AddPtr <t> x (Const64 [c])) -> (OffPtr <t> x [c])
(AddPtr <t> x (Const32 [c])) -> (OffPtr <t> x [c])
(Sub8 (Const8 [c]) (Const8 [d])) -> (Const8 [int64(int8(c-d))])
(Sub16 (Const16 [c]) (Const16 [d])) -> (Const16 [int64(int16(c-d))])
......
......@@ -1823,6 +1823,23 @@ func rewriteValuegeneric_OpAddPtr(v *Value, config *Config) bool {
v.AddArg(x)
return true
}
// match: (AddPtr <t> x (Const32 [c]))
// cond:
// result: (OffPtr <t> x [c])
for {
t := v.Type
x := v.Args[0]
v_1 := v.Args[1]
if v_1.Op != OpConst32 {
break
}
c := v_1.AuxInt
v.reset(OpOffPtr)
v.Type = t
v.AuxInt = c
v.AddArg(x)
return true
}
return false
}
func rewriteValuegeneric_OpAnd16(v *Value, config *Config) bool {
......
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