Commit 9f56845f authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: stop shadowing bool type in rewrite rules

This disrupts code instrumentation tools like go-fuzz.

Change-Id: I524f31316975096ca5e3b1203a82e91ed1b6097e
Reviewed-on: https://go-review.googlesource.com/c/go/+/168801
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 99e22328
......@@ -361,8 +361,8 @@
(FCMPD (FMOVDconst [0]) x) -> (InvertFlags (FCMPD0 x))
// CSEL needs a flag-generating argument. Synthesize a CMPW if necessary.
(CondSelect x y bool) && flagArg(bool) != nil -> (CSEL {bool.Op} x y flagArg(bool))
(CondSelect x y bool) && flagArg(bool) == nil -> (CSEL {OpARM64NotEqual} x y (CMPWconst [0] bool))
(CondSelect x y boolval) && flagArg(boolval) != nil -> (CSEL {boolval.Op} x y flagArg(boolval))
(CondSelect x y boolval) && flagArg(boolval) == nil -> (CSEL {OpARM64NotEqual} x y (CMPWconst [0] boolval))
(OffPtr [off] ptr:(SP)) -> (MOVDaddr [off] ptr)
(OffPtr [off] ptr) -> (ADDconst [off] ptr)
......@@ -1647,14 +1647,14 @@
(CSEL0 {cc} _ flag) && ccARM64Eval(cc, flag) < 0 -> (MOVDconst [0])
// absorb flags back into boolean CSEL
(CSEL {cc} x y (CMPWconst [0] bool)) && cc.(Op) == OpARM64NotEqual && flagArg(bool) != nil ->
(CSEL {bool.Op} x y flagArg(bool))
(CSEL {cc} x y (CMPWconst [0] bool)) && cc.(Op) == OpARM64Equal && flagArg(bool) != nil ->
(CSEL {arm64Negate(bool.Op)} x y flagArg(bool))
(CSEL0 {cc} x (CMPWconst [0] bool)) && cc.(Op) == OpARM64NotEqual && flagArg(bool) != nil ->
(CSEL0 {bool.Op} x flagArg(bool))
(CSEL0 {cc} x (CMPWconst [0] bool)) && cc.(Op) == OpARM64Equal && flagArg(bool) != nil ->
(CSEL0 {arm64Negate(bool.Op)} x flagArg(bool))
(CSEL {cc} x y (CMPWconst [0] boolval)) && cc.(Op) == OpARM64NotEqual && flagArg(boolval) != nil ->
(CSEL {boolval.Op} x y flagArg(boolval))
(CSEL {cc} x y (CMPWconst [0] boolval)) && cc.(Op) == OpARM64Equal && flagArg(boolval) != nil ->
(CSEL {arm64Negate(boolval.Op)} x y flagArg(boolval))
(CSEL0 {cc} x (CMPWconst [0] boolval)) && cc.(Op) == OpARM64NotEqual && flagArg(boolval) != nil ->
(CSEL0 {boolval.Op} x flagArg(boolval))
(CSEL0 {cc} x (CMPWconst [0] boolval)) && cc.(Op) == OpARM64Equal && flagArg(boolval) != nil ->
(CSEL0 {arm64Negate(boolval.Op)} x flagArg(boolval))
// absorb shifts into ops
(NEG x:(SLLconst [c] y)) && clobberIfDead(x) -> (NEGshiftLL [c] y)
......
......@@ -4557,9 +4557,9 @@ func rewriteValueARM64_OpARM64CSEL_0(v *Value) bool {
v.AddArg(y)
return true
}
// match: (CSEL {cc} x y (CMPWconst [0] bool))
// cond: cc.(Op) == OpARM64NotEqual && flagArg(bool) != nil
// result: (CSEL {bool.Op} x y flagArg(bool))
// match: (CSEL {cc} x y (CMPWconst [0] boolval))
// cond: cc.(Op) == OpARM64NotEqual && flagArg(boolval) != nil
// result: (CSEL {boolval.Op} x y flagArg(boolval))
for {
cc := v.Aux
_ = v.Args[2]
......@@ -4572,20 +4572,20 @@ func rewriteValueARM64_OpARM64CSEL_0(v *Value) bool {
if v_2.AuxInt != 0 {
break
}
bool := v_2.Args[0]
if !(cc.(Op) == OpARM64NotEqual && flagArg(bool) != nil) {
boolval := v_2.Args[0]
if !(cc.(Op) == OpARM64NotEqual && flagArg(boolval) != nil) {
break
}
v.reset(OpARM64CSEL)
v.Aux = bool.Op
v.Aux = boolval.Op
v.AddArg(x)
v.AddArg(y)
v.AddArg(flagArg(bool))
v.AddArg(flagArg(boolval))
return true
}
// match: (CSEL {cc} x y (CMPWconst [0] bool))
// cond: cc.(Op) == OpARM64Equal && flagArg(bool) != nil
// result: (CSEL {arm64Negate(bool.Op)} x y flagArg(bool))
// match: (CSEL {cc} x y (CMPWconst [0] boolval))
// cond: cc.(Op) == OpARM64Equal && flagArg(boolval) != nil
// result: (CSEL {arm64Negate(boolval.Op)} x y flagArg(boolval))
for {
cc := v.Aux
_ = v.Args[2]
......@@ -4598,15 +4598,15 @@ func rewriteValueARM64_OpARM64CSEL_0(v *Value) bool {
if v_2.AuxInt != 0 {
break
}
bool := v_2.Args[0]
if !(cc.(Op) == OpARM64Equal && flagArg(bool) != nil) {
boolval := v_2.Args[0]
if !(cc.(Op) == OpARM64Equal && flagArg(boolval) != nil) {
break
}
v.reset(OpARM64CSEL)
v.Aux = arm64Negate(bool.Op)
v.Aux = arm64Negate(boolval.Op)
v.AddArg(x)
v.AddArg(y)
v.AddArg(flagArg(bool))
v.AddArg(flagArg(boolval))
return true
}
return false
......@@ -4658,9 +4658,9 @@ func rewriteValueARM64_OpARM64CSEL0_0(v *Value) bool {
v.AuxInt = 0
return true
}
// match: (CSEL0 {cc} x (CMPWconst [0] bool))
// cond: cc.(Op) == OpARM64NotEqual && flagArg(bool) != nil
// result: (CSEL0 {bool.Op} x flagArg(bool))
// match: (CSEL0 {cc} x (CMPWconst [0] boolval))
// cond: cc.(Op) == OpARM64NotEqual && flagArg(boolval) != nil
// result: (CSEL0 {boolval.Op} x flagArg(boolval))
for {
cc := v.Aux
_ = v.Args[1]
......@@ -4672,19 +4672,19 @@ func rewriteValueARM64_OpARM64CSEL0_0(v *Value) bool {
if v_1.AuxInt != 0 {
break
}
bool := v_1.Args[0]
if !(cc.(Op) == OpARM64NotEqual && flagArg(bool) != nil) {
boolval := v_1.Args[0]
if !(cc.(Op) == OpARM64NotEqual && flagArg(boolval) != nil) {
break
}
v.reset(OpARM64CSEL0)
v.Aux = bool.Op
v.Aux = boolval.Op
v.AddArg(x)
v.AddArg(flagArg(bool))
v.AddArg(flagArg(boolval))
return true
}
// match: (CSEL0 {cc} x (CMPWconst [0] bool))
// cond: cc.(Op) == OpARM64Equal && flagArg(bool) != nil
// result: (CSEL0 {arm64Negate(bool.Op)} x flagArg(bool))
// match: (CSEL0 {cc} x (CMPWconst [0] boolval))
// cond: cc.(Op) == OpARM64Equal && flagArg(boolval) != nil
// result: (CSEL0 {arm64Negate(boolval.Op)} x flagArg(boolval))
for {
cc := v.Aux
_ = v.Args[1]
......@@ -4696,14 +4696,14 @@ func rewriteValueARM64_OpARM64CSEL0_0(v *Value) bool {
if v_1.AuxInt != 0 {
break
}
bool := v_1.Args[0]
if !(cc.(Op) == OpARM64Equal && flagArg(bool) != nil) {
boolval := v_1.Args[0]
if !(cc.(Op) == OpARM64Equal && flagArg(boolval) != nil) {
break
}
v.reset(OpARM64CSEL0)
v.Aux = arm64Negate(bool.Op)
v.Aux = arm64Negate(boolval.Op)
v.AddArg(x)
v.AddArg(flagArg(bool))
v.AddArg(flagArg(boolval))
return true
}
return false
......@@ -32486,31 +32486,31 @@ func rewriteValueARM64_OpCom8_0(v *Value) bool {
}
func rewriteValueARM64_OpCondSelect_0(v *Value) bool {
b := v.Block
// match: (CondSelect x y bool)
// cond: flagArg(bool) != nil
// result: (CSEL {bool.Op} x y flagArg(bool))
// match: (CondSelect x y boolval)
// cond: flagArg(boolval) != nil
// result: (CSEL {boolval.Op} x y flagArg(boolval))
for {
bool := v.Args[2]
boolval := v.Args[2]
x := v.Args[0]
y := v.Args[1]
if !(flagArg(bool) != nil) {
if !(flagArg(boolval) != nil) {
break
}
v.reset(OpARM64CSEL)
v.Aux = bool.Op
v.Aux = boolval.Op
v.AddArg(x)
v.AddArg(y)
v.AddArg(flagArg(bool))
v.AddArg(flagArg(boolval))
return true
}
// match: (CondSelect x y bool)
// cond: flagArg(bool) == nil
// result: (CSEL {OpARM64NotEqual} x y (CMPWconst [0] bool))
// match: (CondSelect x y boolval)
// cond: flagArg(boolval) == nil
// result: (CSEL {OpARM64NotEqual} x y (CMPWconst [0] boolval))
for {
bool := v.Args[2]
boolval := v.Args[2]
x := v.Args[0]
y := v.Args[1]
if !(flagArg(bool) == nil) {
if !(flagArg(boolval) == nil) {
break
}
v.reset(OpARM64CSEL)
......@@ -32519,7 +32519,7 @@ func rewriteValueARM64_OpCondSelect_0(v *Value) bool {
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpARM64CMPWconst, types.TypeFlags)
v0.AuxInt = 0
v0.AddArg(bool)
v0.AddArg(boolval)
v.AddArg(v0)
return true
}
......
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