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>
(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
}
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 {