aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Donizetti <alb.donizetti@gmail.com>2020-04-30 11:04:02 +0200
committerAlberto Donizetti <alb.donizetti@gmail.com>2020-04-30 17:30:54 +0000
commit666c9aedd40853e2fc84bbd743b13cb267007ac2 (patch)
tree43bc80fcf6ac0fa490a69c770ec58996f45032de
parent9ed0fb42e34ff64dd6447572d8bc9dbb05ddb552 (diff)
downloadgo-666c9aedd40853e2fc84bbd743b13cb267007ac2.tar.gz
go-666c9aedd40853e2fc84bbd743b13cb267007ac2.zip
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>
-rw-r--r--src/cmd/compile/internal/arm64/ssa.go2
-rw-r--r--src/cmd/compile/internal/ssa/gen/ARM64.rules24
-rw-r--r--src/cmd/compile/internal/ssa/gen/ARM64Ops.go12
-rw-r--r--src/cmd/compile/internal/ssa/gen/rulegen.go2
-rw-r--r--src/cmd/compile/internal/ssa/opGen.go4
-rw-r--r--src/cmd/compile/internal/ssa/rewrite.go1
-rw-r--r--src/cmd/compile/internal/ssa/rewriteARM64.go72
7 files changed, 61 insertions, 56 deletions
diff --git a/src/cmd/compile/internal/arm64/ssa.go b/src/cmd/compile/internal/arm64/ssa.go
index e7d0f83d82..06c520d76a 100644
--- a/src/cmd/compile/internal/arm64/ssa.go
+++ b/src/cmd/compile/internal/arm64/ssa.go
@@ -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()
diff --git a/src/cmd/compile/internal/ssa/gen/ARM64.rules b/src/cmd/compile/internal/ssa/gen/ARM64.rules
index dd644341de..926a87f69d 100644
--- a/src/cmd/compile/internal/ssa/gen/ARM64.rules
+++ b/src/cmd/compile/internal/ssa/gen/ARM64.rules
@@ -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)
diff --git a/src/cmd/compile/internal/ssa/gen/ARM64Ops.go b/src/cmd/compile/internal/ssa/gen/ARM64Ops.go
index c74d5590e7..964a25b052 100644
--- a/src/cmd/compile/internal/ssa/gen/ARM64Ops.go
+++ b/src/cmd/compile/internal/ssa/gen/ARM64Ops.go
@@ -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},
diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go
index 1b2d86f4d5..0deae280b7 100644
--- a/src/cmd/compile/internal/ssa/gen/rulegen.go
+++ b/src/cmd/compile/internal/ssa/gen/rulegen.go
@@ -1842,6 +1842,8 @@ func (b blockData) auxIntType() string {
return "int8"
case "S390XCCMaskUint8":
return "uint8"
+ case "Int64":
+ return "int64"
default:
return "invalid"
}
diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go
index 3185f34fa5..d619f36cf5 100644
--- a/src/cmd/compile/internal/ssa/opGen.go
+++ b/src/cmd/compile/internal/ssa/opGen.go
@@ -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:
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index d5ed11d802..d97497e24f 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -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
}
diff --git a/src/cmd/compile/internal/ssa/rewriteARM64.go b/src/cmd/compile/internal/ssa/rewriteARM64.go
index d6cfb0eea4..e820c2438c 100644
--- a/src/cmd/compile/internal/ssa/rewriteARM64.go
+++ b/src/cmd/compile/internal/ssa/rewriteARM64.go
@@ -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)