]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove ntz function
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 21 Apr 2020 17:52:19 +0000 (00:52 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 22 Apr 2020 08:04:58 +0000 (08:04 +0000)
Use ntzX variants instead.

Passes toolstash-check -a.

Change-Id: I7a627f46f75c3d339034bd3e81c190cea5409c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/229140
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/ssa/gen/ARM64.rules
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/rewriteARM64.go

index 2eab67701a2169bb37e4e8c3ba52dd9cad244370..8478c1c678cba219a7ab414e491294f1cc3138db 100644 (file)
 (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  {ntz(c)} x yes no)
-(NZ (ANDconst [c] x) yes no) && oneBit(c) -> (TBNZ {ntz(c)} x yes no)
-(ZW  (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBZ  {ntz(int64(uint32(c)))} x yes no)
-(NZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBNZ {ntz(int64(uint32(c)))} x yes no)
-(EQ (TSTconst [c] x) yes no) && oneBit(c) -> (TBZ  {ntz(c)} x yes no)
-(NE (TSTconst [c] x) yes no) && oneBit(c) -> (TBNZ {ntz(c)} x yes no)
-(EQ (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBZ  {ntz(int64(uint32(c)))} x yes no)
-(NE (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBNZ {ntz(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)
index 40cb750d83f15b1db7f908138859aa854d93d158..adda7fae93492e8775273fa617bf960583535d14 100644 (file)
@@ -392,7 +392,6 @@ func nlz16(x int16) int { return bits.LeadingZeros16(uint16(x)) }
 func nlz8(x int8) int   { return bits.LeadingZeros8(uint8(x)) }
 
 // ntzX returns the number of trailing zeros.
-func ntz(x int64) int64 { return int64(bits.TrailingZeros64(uint64(x))) } // TODO: remove when no longer used
 func ntz64(x int64) int { return bits.TrailingZeros64(uint64(x)) }
 func ntz32(x int32) int { return bits.TrailingZeros32(uint32(x)) }
 func ntz16(x int16) int { return bits.TrailingZeros16(uint16(x)) }
@@ -406,7 +405,7 @@ func oneBit64(x int64) bool { return x&(x-1) == 0 && x != 0 }
 
 // nto returns the number of trailing ones.
 func nto(x int64) int64 {
-       return ntz(^x)
+       return int64(ntz64(^x))
 }
 
 // log2 returns logarithm in base 2 of uint64(n), with log2(0) = -1.
index 768c17912406157e8f05ba9f2245ec8ec61b408d..c77cf8978af057b6d2b976c8ff03694924b55bcf 100644 (file)
@@ -26073,7 +26073,7 @@ func rewriteBlockARM64(b *Block) bool {
                }
                // match: (EQ (TSTconst [c] x) yes no)
                // cond: oneBit(c)
-               // result: (TBZ {ntz(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
@@ -26082,12 +26082,12 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBZ, x)
-                       b.Aux = ntz(c)
+                       b.Aux = int64(ntz64(c))
                        return true
                }
                // match: (EQ (TSTWconst [c] x) yes no)
                // cond: oneBit(int64(uint32(c)))
-               // result: (TBZ {ntz(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
@@ -26096,7 +26096,7 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBZ, x)
-                       b.Aux = ntz(int64(uint32(c)))
+                       b.Aux = int64(ntz64(int64(uint32(c))))
                        return true
                }
                // match: (EQ (FlagEQ) yes no)
@@ -28256,7 +28256,7 @@ func rewriteBlockARM64(b *Block) bool {
                }
                // match: (NE (TSTconst [c] x) yes no)
                // cond: oneBit(c)
-               // result: (TBNZ {ntz(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
@@ -28265,12 +28265,12 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBNZ, x)
-                       b.Aux = ntz(c)
+                       b.Aux = int64(ntz64(c))
                        return true
                }
                // match: (NE (TSTWconst [c] x) yes no)
                // cond: oneBit(int64(uint32(c)))
-               // result: (TBNZ {ntz(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
@@ -28279,7 +28279,7 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBNZ, x)
-                       b.Aux = ntz(int64(uint32(c)))
+                       b.Aux = int64(ntz64(int64(uint32(c))))
                        return true
                }
                // match: (NE (FlagEQ) yes no)
@@ -28436,7 +28436,7 @@ func rewriteBlockARM64(b *Block) bool {
                }
                // match: (NZ (ANDconst [c] x) yes no)
                // cond: oneBit(c)
-               // result: (TBNZ {ntz(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
@@ -28445,7 +28445,7 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBNZ, x)
-                       b.Aux = ntz(c)
+                       b.Aux = int64(ntz64(c))
                        return true
                }
                // match: (NZ (MOVDconst [0]) yes no)
@@ -28474,7 +28474,7 @@ func rewriteBlockARM64(b *Block) bool {
        case BlockARM64NZW:
                // match: (NZW (ANDconst [c] x) yes no)
                // cond: oneBit(int64(uint32(c)))
-               // result: (TBNZ {ntz(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
@@ -28483,7 +28483,7 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBNZ, x)
-                       b.Aux = ntz(int64(uint32(c)))
+                       b.Aux = int64(ntz64(int64(uint32(c))))
                        return true
                }
                // match: (NZW (MOVDconst [c]) yes no)
@@ -28680,7 +28680,7 @@ func rewriteBlockARM64(b *Block) bool {
        case BlockARM64Z:
                // match: (Z (ANDconst [c] x) yes no)
                // cond: oneBit(c)
-               // result: (TBZ {ntz(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
@@ -28689,7 +28689,7 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBZ, x)
-                       b.Aux = ntz(c)
+                       b.Aux = int64(ntz64(c))
                        return true
                }
                // match: (Z (MOVDconst [0]) yes no)
@@ -28718,7 +28718,7 @@ func rewriteBlockARM64(b *Block) bool {
        case BlockARM64ZW:
                // match: (ZW (ANDconst [c] x) yes no)
                // cond: oneBit(int64(uint32(c)))
-               // result: (TBZ {ntz(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
@@ -28727,7 +28727,7 @@ func rewriteBlockARM64(b *Block) bool {
                                break
                        }
                        b.resetWithControl(BlockARM64TBZ, x)
-                       b.Aux = ntz(int64(uint32(c)))
+                       b.Aux = int64(ntz64(int64(uint32(c))))
                        return true
                }
                // match: (ZW (MOVDconst [c]) yes no)