mirror of
https://github.com/golang/go
synced 2024-11-23 23:50:08 -07:00
cmd/compile: switch to typed auxint for arm64 TBZ/TBNZ block
This CL changes the arm64 TBZ/TBNZ block from using Aux to using a (typed) AuxInt. The corresponding rules have also been changed to be typed. Passes GOARCH=arm64 gotip build -toolexec 'toolstash -cmp' -a std Change-Id: I98d0cd2a791948f1db13259c17fb1b9b2807a043 Reviewed-on: https://go-review.googlesource.com/c/go/+/230839 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
9ed0fb42e3
commit
666c9aedd4
@ -1083,7 +1083,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
|
||||
s.Br(obj.AJMP, b.Succs[0].Block())
|
||||
}
|
||||
}
|
||||
p.From.Offset = b.Aux.(int64)
|
||||
p.From.Offset = b.AuxInt
|
||||
p.From.Type = obj.TYPE_CONST
|
||||
p.Reg = b.Controls[0].Reg()
|
||||
|
||||
|
@ -672,20 +672,20 @@
|
||||
(GT (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (GT (CMPW a (MULW <x.Type> x y)) yes no)
|
||||
|
||||
// Absorb bit-tests into block
|
||||
(Z (ANDconst [c] x) yes no) && oneBit(c) -> (TBZ {int64(ntz64(c))} x yes no)
|
||||
(NZ (ANDconst [c] x) yes no) && oneBit(c) -> (TBNZ {int64(ntz64(c))} x yes no)
|
||||
(ZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
(NZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBNZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
(EQ (TSTconst [c] x) yes no) && oneBit(c) -> (TBZ {int64(ntz64(c))} x yes no)
|
||||
(NE (TSTconst [c] x) yes no) && oneBit(c) -> (TBNZ {int64(ntz64(c))} x yes no)
|
||||
(EQ (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
(NE (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBNZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
(Z (ANDconst [c] x) yes no) && oneBit(c) => (TBZ [int64(ntz64(c))] x yes no)
|
||||
(NZ (ANDconst [c] x) yes no) && oneBit(c) => (TBNZ [int64(ntz64(c))] x yes no)
|
||||
(ZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
(NZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
(EQ (TSTconst [c] x) yes no) && oneBit(c) => (TBZ [int64(ntz64(c))] x yes no)
|
||||
(NE (TSTconst [c] x) yes no) && oneBit(c) => (TBNZ [int64(ntz64(c))] x yes no)
|
||||
(EQ (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
(NE (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
|
||||
// Test sign-bit for signed comparisons against zero
|
||||
(GE (CMPWconst [0] x) yes no) -> (TBZ {int64(31)} x yes no)
|
||||
(GE (CMPconst [0] x) yes no) -> (TBZ {int64(63)} x yes no)
|
||||
(LT (CMPWconst [0] x) yes no) -> (TBNZ {int64(31)} x yes no)
|
||||
(LT (CMPconst [0] x) yes no) -> (TBNZ {int64(63)} x yes no)
|
||||
(GE (CMPWconst [0] x) yes no) => (TBZ [31] x yes no)
|
||||
(GE (CMPconst [0] x) yes no) => (TBZ [63] x yes no)
|
||||
(LT (CMPWconst [0] x) yes no) => (TBNZ [31] x yes no)
|
||||
(LT (CMPconst [0] x) yes no) => (TBNZ [63] x yes no)
|
||||
|
||||
// fold offset into address
|
||||
(ADDconst [off1] (MOVDaddr [off2] {sym} ptr)) -> (MOVDaddr [off1+off2] {sym} ptr)
|
||||
|
@ -691,12 +691,12 @@ func init() {
|
||||
{name: "ULE", controls: 1},
|
||||
{name: "UGT", controls: 1},
|
||||
{name: "UGE", controls: 1},
|
||||
{name: "Z", controls: 1}, // Control == 0 (take a register instead of flags)
|
||||
{name: "NZ", controls: 1}, // Control != 0
|
||||
{name: "ZW", controls: 1}, // Control == 0, 32-bit
|
||||
{name: "NZW", controls: 1}, // Control != 0, 32-bit
|
||||
{name: "TBZ", controls: 1}, // Control & (1 << Aux.(int64)) == 0
|
||||
{name: "TBNZ", controls: 1}, // Control & (1 << Aux.(int64)) != 0
|
||||
{name: "Z", controls: 1}, // Control == 0 (take a register instead of flags)
|
||||
{name: "NZ", controls: 1}, // Control != 0
|
||||
{name: "ZW", controls: 1}, // Control == 0, 32-bit
|
||||
{name: "NZW", controls: 1}, // Control != 0, 32-bit
|
||||
{name: "TBZ", controls: 1, aux: "Int64"}, // Control & (1 << AuxInt) == 0
|
||||
{name: "TBNZ", controls: 1, aux: "Int64"}, // Control & (1 << AuxInt) != 0
|
||||
{name: "FLT", controls: 1},
|
||||
{name: "FLE", controls: 1},
|
||||
{name: "FGT", controls: 1},
|
||||
|
@ -1842,6 +1842,8 @@ func (b blockData) auxIntType() string {
|
||||
return "int8"
|
||||
case "S390XCCMaskUint8":
|
||||
return "uint8"
|
||||
case "Int64":
|
||||
return "int64"
|
||||
default:
|
||||
return "invalid"
|
||||
}
|
||||
|
@ -277,6 +277,10 @@ var blockString = [...]string{
|
||||
func (k BlockKind) String() string { return blockString[k] }
|
||||
func (k BlockKind) AuxIntType() string {
|
||||
switch k {
|
||||
case BlockARM64TBZ:
|
||||
return "int64"
|
||||
case BlockARM64TBNZ:
|
||||
return "int64"
|
||||
case BlockS390XCIJ:
|
||||
return "int8"
|
||||
case BlockS390XCGIJ:
|
||||
|
@ -687,7 +687,6 @@ func s390xCCMaskToAux(c s390x.CCMask) interface{} {
|
||||
func s390xRotateParamsToAux(r s390x.RotateParams) interface{} {
|
||||
return r
|
||||
}
|
||||
|
||||
func cCopToAux(o Op) interface{} {
|
||||
return o
|
||||
}
|
||||
|
@ -26071,30 +26071,30 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
}
|
||||
// match: (EQ (TSTconst [c] x) yes no)
|
||||
// cond: oneBit(c)
|
||||
// result: (TBZ {int64(ntz64(c))} x yes no)
|
||||
// result: (TBZ [int64(ntz64(c))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64TSTconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt64(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(c)) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBZ, x)
|
||||
b.Aux = int64(ntz64(c))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(c)))
|
||||
return true
|
||||
}
|
||||
// match: (EQ (TSTWconst [c] x) yes no)
|
||||
// cond: oneBit(int64(uint32(c)))
|
||||
// result: (TBZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
// result: (TBZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64TSTWconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt32(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(int64(uint32(c)))) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBZ, x)
|
||||
b.Aux = int64(ntz64(int64(uint32(c))))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c)))))
|
||||
return true
|
||||
}
|
||||
// match: (EQ (FlagEQ) yes no)
|
||||
@ -26521,27 +26521,27 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
return true
|
||||
}
|
||||
// match: (GE (CMPWconst [0] x) yes no)
|
||||
// result: (TBZ {int64(31)} x yes no)
|
||||
// result: (TBZ [31] x yes no)
|
||||
for b.Controls[0].Op == OpARM64CMPWconst {
|
||||
v_0 := b.Controls[0]
|
||||
if v_0.AuxInt != 0 {
|
||||
if auxIntToInt32(v_0.AuxInt) != 0 {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
b.resetWithControl(BlockARM64TBZ, x)
|
||||
b.Aux = int64(31)
|
||||
b.AuxInt = int64ToAuxInt(31)
|
||||
return true
|
||||
}
|
||||
// match: (GE (CMPconst [0] x) yes no)
|
||||
// result: (TBZ {int64(63)} x yes no)
|
||||
// result: (TBZ [63] x yes no)
|
||||
for b.Controls[0].Op == OpARM64CMPconst {
|
||||
v_0 := b.Controls[0]
|
||||
if v_0.AuxInt != 0 {
|
||||
if auxIntToInt64(v_0.AuxInt) != 0 {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
b.resetWithControl(BlockARM64TBZ, x)
|
||||
b.Aux = int64(63)
|
||||
b.AuxInt = int64ToAuxInt(63)
|
||||
return true
|
||||
}
|
||||
// match: (GE (FlagEQ) yes no)
|
||||
@ -27821,27 +27821,27 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
return true
|
||||
}
|
||||
// match: (LT (CMPWconst [0] x) yes no)
|
||||
// result: (TBNZ {int64(31)} x yes no)
|
||||
// result: (TBNZ [31] x yes no)
|
||||
for b.Controls[0].Op == OpARM64CMPWconst {
|
||||
v_0 := b.Controls[0]
|
||||
if v_0.AuxInt != 0 {
|
||||
if auxIntToInt32(v_0.AuxInt) != 0 {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
b.resetWithControl(BlockARM64TBNZ, x)
|
||||
b.Aux = int64(31)
|
||||
b.AuxInt = int64ToAuxInt(31)
|
||||
return true
|
||||
}
|
||||
// match: (LT (CMPconst [0] x) yes no)
|
||||
// result: (TBNZ {int64(63)} x yes no)
|
||||
// result: (TBNZ [63] x yes no)
|
||||
for b.Controls[0].Op == OpARM64CMPconst {
|
||||
v_0 := b.Controls[0]
|
||||
if v_0.AuxInt != 0 {
|
||||
if auxIntToInt64(v_0.AuxInt) != 0 {
|
||||
break
|
||||
}
|
||||
x := v_0.Args[0]
|
||||
b.resetWithControl(BlockARM64TBNZ, x)
|
||||
b.Aux = int64(63)
|
||||
b.AuxInt = int64ToAuxInt(63)
|
||||
return true
|
||||
}
|
||||
// match: (LT (FlagEQ) yes no)
|
||||
@ -28254,30 +28254,30 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
}
|
||||
// match: (NE (TSTconst [c] x) yes no)
|
||||
// cond: oneBit(c)
|
||||
// result: (TBNZ {int64(ntz64(c))} x yes no)
|
||||
// result: (TBNZ [int64(ntz64(c))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64TSTconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt64(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(c)) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBNZ, x)
|
||||
b.Aux = int64(ntz64(c))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(c)))
|
||||
return true
|
||||
}
|
||||
// match: (NE (TSTWconst [c] x) yes no)
|
||||
// cond: oneBit(int64(uint32(c)))
|
||||
// result: (TBNZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
// result: (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64TSTWconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt32(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(int64(uint32(c)))) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBNZ, x)
|
||||
b.Aux = int64(ntz64(int64(uint32(c))))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c)))))
|
||||
return true
|
||||
}
|
||||
// match: (NE (FlagEQ) yes no)
|
||||
@ -28434,16 +28434,16 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
}
|
||||
// match: (NZ (ANDconst [c] x) yes no)
|
||||
// cond: oneBit(c)
|
||||
// result: (TBNZ {int64(ntz64(c))} x yes no)
|
||||
// result: (TBNZ [int64(ntz64(c))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64ANDconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt64(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(c)) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBNZ, x)
|
||||
b.Aux = int64(ntz64(c))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(c)))
|
||||
return true
|
||||
}
|
||||
// match: (NZ (MOVDconst [0]) yes no)
|
||||
@ -28472,16 +28472,16 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
case BlockARM64NZW:
|
||||
// match: (NZW (ANDconst [c] x) yes no)
|
||||
// cond: oneBit(int64(uint32(c)))
|
||||
// result: (TBNZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
// result: (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64ANDconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt64(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(int64(uint32(c)))) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBNZ, x)
|
||||
b.Aux = int64(ntz64(int64(uint32(c))))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c)))))
|
||||
return true
|
||||
}
|
||||
// match: (NZW (MOVDconst [c]) yes no)
|
||||
@ -28678,16 +28678,16 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
case BlockARM64Z:
|
||||
// match: (Z (ANDconst [c] x) yes no)
|
||||
// cond: oneBit(c)
|
||||
// result: (TBZ {int64(ntz64(c))} x yes no)
|
||||
// result: (TBZ [int64(ntz64(c))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64ANDconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt64(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(c)) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBZ, x)
|
||||
b.Aux = int64(ntz64(c))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(c)))
|
||||
return true
|
||||
}
|
||||
// match: (Z (MOVDconst [0]) yes no)
|
||||
@ -28716,16 +28716,16 @@ func rewriteBlockARM64(b *Block) bool {
|
||||
case BlockARM64ZW:
|
||||
// match: (ZW (ANDconst [c] x) yes no)
|
||||
// cond: oneBit(int64(uint32(c)))
|
||||
// result: (TBZ {int64(ntz64(int64(uint32(c))))} x yes no)
|
||||
// result: (TBZ [int64(ntz64(int64(uint32(c))))] x yes no)
|
||||
for b.Controls[0].Op == OpARM64ANDconst {
|
||||
v_0 := b.Controls[0]
|
||||
c := v_0.AuxInt
|
||||
c := auxIntToInt64(v_0.AuxInt)
|
||||
x := v_0.Args[0]
|
||||
if !(oneBit(int64(uint32(c)))) {
|
||||
break
|
||||
}
|
||||
b.resetWithControl(BlockARM64TBZ, x)
|
||||
b.Aux = int64(ntz64(int64(uint32(c))))
|
||||
b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c)))))
|
||||
return true
|
||||
}
|
||||
// match: (ZW (MOVDconst [c]) yes no)
|
||||
|
Loading…
Reference in New Issue
Block a user