]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use NOT pseudo-instruction for riscv64 Slicemask
authorJoel Sing <joel@sing.id.au>
Sun, 15 Mar 2020 16:29:19 +0000 (03:29 +1100)
committerJoel Sing <joel@sing.id.au>
Tue, 17 Mar 2020 01:24:30 +0000 (01:24 +0000)
Change-Id: Idefb6669d54929065f57e3bd767c91451dc3a375
Reviewed-on: https://go-review.googlesource.com/c/go/+/223562
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/ssa/gen/RISCV64.rules
src/cmd/compile/internal/ssa/rewriteRISCV64.go

index a4b141b4fb9d87bb5f120e732ae6bf2d16757be6..fba431368b6e1662ab663e759f044d97f2b604d1 100644 (file)
 // For positive x, bit 63 of x-1 is always 0, so the result is -1.
 // For zero x, bit 63 of x-1 is 1, so the result is 0.
 //
-(Slicemask <t> x) -> (XORI [-1] (SRAI <t> [63] (ADDI <t> [-1] x)))
+(Slicemask <t> x) -> (NOT (SRAI <t> [63] (ADDI <t> [-1] x)))
 
 // Truncations
 // We ignore the unused high parts of registers, so truncates are just copies.
index 692cd92cc855f82f4a41b44fa794278bcbd734cc..a7b0ba05b912adb7b711b3e16990da4e3b9c50b7 100644 (file)
@@ -4309,12 +4309,11 @@ func rewriteValueRISCV64_OpSlicemask(v *Value) bool {
        v_0 := v.Args[0]
        b := v.Block
        // match: (Slicemask <t> x)
-       // result: (XORI [-1] (SRAI <t> [63] (ADDI <t> [-1] x)))
+       // result: (NOT (SRAI <t> [63] (ADDI <t> [-1] x)))
        for {
                t := v.Type
                x := v_0
-               v.reset(OpRISCV64XORI)
-               v.AuxInt = -1
+               v.reset(OpRISCV64NOT)
                v0 := b.NewValue0(v.Pos, OpRISCV64SRAI, t)
                v0.AuxInt = 63
                v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, t)