mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: optimize Add64carry with unused carries into plain Add64
Change-Id: I8a63f567cfc574bb066ad6269eec6929760cb9c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/656338 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
parent
2ce5aab79e
commit
5453b788fd
2 changed files with 23 additions and 0 deletions
|
|
@ -629,6 +629,10 @@
|
|||
(Sub(64|32|16|8) (Com(64|32|16|8) x) (Neg(64|32|16|8) x)) => (Const(64|32|16|8) [-1])
|
||||
(Add(64|32|16|8) (Com(64|32|16|8) x) x) => (Const(64|32|16|8) [-1])
|
||||
|
||||
// Prove does not simplify this because x + y might overflow into carry,
|
||||
// however if no one care about the carry, let it overflow in a normal add.
|
||||
(Select0 a:(Add64carry x y (Const64 [0]))) && a.Uses == 1 => (Add64 x y)
|
||||
|
||||
// Simplification when involving common integer
|
||||
// (t + x) - (t + y) == x - y
|
||||
// (t + x) - (y + t) == x - y
|
||||
|
|
|
|||
|
|
@ -30274,6 +30274,25 @@ func rewriteValuegeneric_OpRsh8x8(v *Value) bool {
|
|||
}
|
||||
func rewriteValuegeneric_OpSelect0(v *Value) bool {
|
||||
v_0 := v.Args[0]
|
||||
// match: (Select0 a:(Add64carry x y (Const64 [0])))
|
||||
// cond: a.Uses == 1
|
||||
// result: (Add64 x y)
|
||||
for {
|
||||
a := v_0
|
||||
if a.Op != OpAdd64carry {
|
||||
break
|
||||
}
|
||||
_ = a.Args[2]
|
||||
x := a.Args[0]
|
||||
y := a.Args[1]
|
||||
a_2 := a.Args[2]
|
||||
if a_2.Op != OpConst64 || auxIntToInt64(a_2.AuxInt) != 0 || !(a.Uses == 1) {
|
||||
break
|
||||
}
|
||||
v.reset(OpAdd64)
|
||||
v.AddArg2(x, y)
|
||||
return true
|
||||
}
|
||||
// match: (Select0 (MakeTuple x y))
|
||||
// result: x
|
||||
for {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue