mirror of
https://github.com/golang/go
synced 2024-09-29 12:24:31 -06:00
cmd/compile: optimise x ^ ^x
This commit is contained in:
parent
4e3ac1190c
commit
ce35ff2efd
@ -526,6 +526,7 @@
|
||||
|
||||
(Xor(64|32|16|8) x x) => (Const(64|32|16|8) [0])
|
||||
(Xor(64|32|16|8) (Const(64|32|16|8) [0]) x) => x
|
||||
(Xor(64|32|16|8) (Com(64|32|16|8) x) x) => (Const(64|32|16|8) [-1])
|
||||
|
||||
(Add(64|32|16|8) (Const(64|32|16|8) [0]) x) => x
|
||||
(Sub(64|32|16|8) x x) => (Const(64|32|16|8) [0])
|
||||
|
@ -25090,6 +25090,23 @@ func rewriteValuegeneric_OpXor16(v *Value) bool {
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor16 (Com16 x) x)
|
||||
// result: (Const16 [-1])
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
if v_0.Op != OpCom16 {
|
||||
continue
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
if x != v_1 {
|
||||
continue
|
||||
}
|
||||
v.reset(OpConst16)
|
||||
v.AuxInt = int16ToAuxInt(-1)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor16 (Const16 [-1]) x)
|
||||
// result: (Com16 x)
|
||||
for {
|
||||
@ -25235,6 +25252,23 @@ func rewriteValuegeneric_OpXor32(v *Value) bool {
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor32 (Com32 x) x)
|
||||
// result: (Const32 [-1])
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
if v_0.Op != OpCom32 {
|
||||
continue
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
if x != v_1 {
|
||||
continue
|
||||
}
|
||||
v.reset(OpConst32)
|
||||
v.AuxInt = int32ToAuxInt(-1)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor32 (Const32 [-1]) x)
|
||||
// result: (Com32 x)
|
||||
for {
|
||||
@ -25380,6 +25414,23 @@ func rewriteValuegeneric_OpXor64(v *Value) bool {
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor64 (Com64 x) x)
|
||||
// result: (Const64 [-1])
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
if v_0.Op != OpCom64 {
|
||||
continue
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
if x != v_1 {
|
||||
continue
|
||||
}
|
||||
v.reset(OpConst64)
|
||||
v.AuxInt = int64ToAuxInt(-1)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor64 (Const64 [-1]) x)
|
||||
// result: (Com64 x)
|
||||
for {
|
||||
@ -25525,6 +25576,23 @@ func rewriteValuegeneric_OpXor8(v *Value) bool {
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor8 (Com8 x) x)
|
||||
// result: (Const8 [-1])
|
||||
for {
|
||||
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
|
||||
if v_0.Op != OpCom8 {
|
||||
continue
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
if x != v_1 {
|
||||
continue
|
||||
}
|
||||
v.reset(OpConst8)
|
||||
v.AuxInt = int8ToAuxInt(-1)
|
||||
return true
|
||||
}
|
||||
break
|
||||
}
|
||||
// match: (Xor8 (Const8 [-1]) x)
|
||||
// result: (Com8 x)
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user