Skip to content

Commit

Permalink
cmd/compile: switch to typed auxint for arm64 TBZ/TBNZ block
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ALTree committed Apr 30, 2020
1 parent 9ed0fb4 commit 666c9ae
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/arm64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
24 changes: 12 additions & 12 deletions src/cmd/compile/internal/ssa/gen/ARM64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/compile/internal/ssa/gen/ARM64Ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/compile/internal/ssa/gen/rulegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,8 @@ func (b blockData) auxIntType() string {
return "int8"
case "S390XCCMaskUint8":
return "uint8"
case "Int64":
return "int64"
default:
return "invalid"
}
Expand Down
4 changes: 4 additions & 0 deletions src/cmd/compile/internal/ssa/opGen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/cmd/compile/internal/ssa/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
72 changes: 36 additions & 36 deletions src/cmd/compile/internal/ssa/rewriteARM64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 666c9ae

Please sign in to comment.