From 2b622b05a97bf785e97a3c241270cb6580d65ef7 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 4 Aug 2025 19:17:10 +0700 Subject: [PATCH] cmd/compile: remove isUintXPowerOfTwo functions And use the generic version instead. While at it, also correct the corresponding rules to use logXu variants instead of logXu, following discussion in CL 689815. Change-Id: Iba85d14ff0e26d45a126764e7bd5702586358d23 Reviewed-on: https://go-review.googlesource.com/c/go/+/692917 Reviewed-by: Keith Randall Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Auto-Submit: Cuong Manh Le Reviewed-by: Dmitri Shuralyov --- src/cmd/compile/internal/ssa/_gen/AMD64.rules | 40 ++--- src/cmd/compile/internal/ssa/rewrite.go | 6 - src/cmd/compile/internal/ssa/rewriteAMD64.go | 168 +++++++++--------- 3 files changed, 104 insertions(+), 110 deletions(-) diff --git a/src/cmd/compile/internal/ssa/_gen/AMD64.rules b/src/cmd/compile/internal/ssa/_gen/AMD64.rules index 95e6300126..1e0a599570 100644 --- a/src/cmd/compile/internal/ssa/_gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/_gen/AMD64.rules @@ -606,31 +606,31 @@ // mutandis, for UGE and SETAE, and CC and SETCC. ((NE|EQ) (TESTL (SHLL (MOVLconst [1]) x) y)) => ((ULT|UGE) (BTL x y)) ((NE|EQ) (TESTQ (SHLQ (MOVQconst [1]) x) y)) => ((ULT|UGE) (BTQ x y)) -((NE|EQ) (TESTLconst [c] x)) && isUint32PowerOfTwo(int64(c)) - => ((ULT|UGE) (BTLconst [int8(log32(c))] x)) -((NE|EQ) (TESTQconst [c] x)) && isUint64PowerOfTwo(int64(c)) - => ((ULT|UGE) (BTQconst [int8(log32(c))] x)) -((NE|EQ) (TESTQ (MOVQconst [c]) x)) && isUint64PowerOfTwo(c) - => ((ULT|UGE) (BTQconst [int8(log64(c))] x)) +((NE|EQ) (TESTLconst [c] x)) && isUnsignedPowerOfTwo(uint32(c)) + => ((ULT|UGE) (BTLconst [int8(log32u(uint32(c)))] x)) +((NE|EQ) (TESTQconst [c] x)) && isUnsignedPowerOfTwo(uint64(c)) + => ((ULT|UGE) (BTQconst [int8(log32u(uint32(c)))] x)) +((NE|EQ) (TESTQ (MOVQconst [c]) x)) && isUnsignedPowerOfTwo(uint64(c)) + => ((ULT|UGE) (BTQconst [int8(log64u(uint64(c)))] x)) (SET(NE|EQ) (TESTL (SHLL (MOVLconst [1]) x) y)) => (SET(B|AE) (BTL x y)) (SET(NE|EQ) (TESTQ (SHLQ (MOVQconst [1]) x) y)) => (SET(B|AE) (BTQ x y)) -(SET(NE|EQ) (TESTLconst [c] x)) && isUint32PowerOfTwo(int64(c)) - => (SET(B|AE) (BTLconst [int8(log32(c))] x)) -(SET(NE|EQ) (TESTQconst [c] x)) && isUint64PowerOfTwo(int64(c)) - => (SET(B|AE) (BTQconst [int8(log32(c))] x)) -(SET(NE|EQ) (TESTQ (MOVQconst [c]) x)) && isUint64PowerOfTwo(c) - => (SET(B|AE) (BTQconst [int8(log64(c))] x)) +(SET(NE|EQ) (TESTLconst [c] x)) && isUnsignedPowerOfTwo(uint32(c)) + => (SET(B|AE) (BTLconst [int8(log32u(uint32(c)))] x)) +(SET(NE|EQ) (TESTQconst [c] x)) && isUnsignedPowerOfTwo(uint64(c)) + => (SET(B|AE) (BTQconst [int8(log32u(uint32(c)))] x)) +(SET(NE|EQ) (TESTQ (MOVQconst [c]) x)) && isUnsignedPowerOfTwo(uint64(c)) + => (SET(B|AE) (BTQconst [int8(log64u(uint64(c)))] x)) // SET..store variant (SET(NE|EQ)store [off] {sym} ptr (TESTL (SHLL (MOVLconst [1]) x) y) mem) => (SET(B|AE)store [off] {sym} ptr (BTL x y) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTQ (SHLQ (MOVQconst [1]) x) y) mem) => (SET(B|AE)store [off] {sym} ptr (BTQ x y) mem) -(SET(NE|EQ)store [off] {sym} ptr (TESTLconst [c] x) mem) && isUint32PowerOfTwo(int64(c)) - => (SET(B|AE)store [off] {sym} ptr (BTLconst [int8(log32(c))] x) mem) -(SET(NE|EQ)store [off] {sym} ptr (TESTQconst [c] x) mem) && isUint64PowerOfTwo(int64(c)) - => (SET(B|AE)store [off] {sym} ptr (BTQconst [int8(log32(c))] x) mem) -(SET(NE|EQ)store [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) && isUint64PowerOfTwo(c) - => (SET(B|AE)store [off] {sym} ptr (BTQconst [int8(log64(c))] x) mem) +(SET(NE|EQ)store [off] {sym} ptr (TESTLconst [c] x) mem) && isUnsignedPowerOfTwo(uint32(c)) + => (SET(B|AE)store [off] {sym} ptr (BTLconst [int8(log32u(uint32(c)))] x) mem) +(SET(NE|EQ)store [off] {sym} ptr (TESTQconst [c] x) mem) && isUnsignedPowerOfTwo(uint64(c)) + => (SET(B|AE)store [off] {sym} ptr (BTQconst [int8(log32u(uint32(c)))] x) mem) +(SET(NE|EQ)store [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) && isUnsignedPowerOfTwo(uint64(c)) + => (SET(B|AE)store [off] {sym} ptr (BTQconst [int8(log64u(uint64(c)))] x) mem) // Handle bit-testing in the form (a>>b)&1 != 0 by building the above rules // and further combining shifts. @@ -655,14 +655,14 @@ (XOR(Q|L) (SHL(Q|L) (MOV(Q|L)const [1]) y) x) => (BTC(Q|L) x y) // Note: only convert OR/XOR to BTS/BTC if the constant wouldn't fit in // the constant field of the OR/XOR instruction. See issue 61694. -((OR|XOR)Q (MOVQconst [c]) x) && isUint64PowerOfTwo(c) && uint64(c) >= 1<<31 => (BT(S|C)Qconst [int8(log64(c))] x) +((OR|XOR)Q (MOVQconst [c]) x) && isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31 => (BT(S|C)Qconst [int8(log64u(uint64(c)))] x) // Recognize bit clearing: a &^= 1< (BTR(Q|L) x y) (ANDN(Q|L) x (SHL(Q|L) (MOV(Q|L)const [1]) y)) => (BTR(Q|L) x y) // Note: only convert AND to BTR if the constant wouldn't fit in // the constant field of the AND instruction. See issue 61694. -(ANDQ (MOVQconst [c]) x) && isUint64PowerOfTwo(^c) && uint64(^c) >= 1<<31 => (BTRQconst [int8(log64(^c))] x) +(ANDQ (MOVQconst [c]) x) && isUnsignedPowerOfTwo(uint64(^c)) && uint64(^c) >= 1<<31 => (BTRQconst [int8(log64u(uint64(^c)))] x) // Special-case bit patterns on first/last bit. // generic.rules changes ANDs of high-part/low-part masks into a couple of shifts, diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 0d000370d5..200318ceb5 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -504,12 +504,6 @@ func isUnsignedPowerOfTwo[T uint8 | uint16 | uint32 | uint64](n T) bool { return n != 0 && n&(n-1) == 0 } -// isUint64PowerOfTwo reports whether uint64(n) is a power of 2. -func isUint64PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint64(in)) } - -// isUint32PowerOfTwo reports whether uint32(n) is a power of 2. -func isUint32PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint32(in)) } - // is32Bit reports whether n can be represented as a signed 32 bit integer. func is32Bit(n int64) bool { return n == int64(int32(n)) diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index 3532d42b0c..c83890aee6 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -3108,8 +3108,8 @@ func rewriteValueAMD64_OpAMD64ANDQ(v *Value) bool { break } // match: (ANDQ (MOVQconst [c]) x) - // cond: isUint64PowerOfTwo(^c) && uint64(^c) >= 1<<31 - // result: (BTRQconst [int8(log64(^c))] x) + // cond: isUnsignedPowerOfTwo(uint64(^c)) && uint64(^c) >= 1<<31 + // result: (BTRQconst [int8(log64u(uint64(^c)))] x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAMD64MOVQconst { @@ -3117,11 +3117,11 @@ func rewriteValueAMD64_OpAMD64ANDQ(v *Value) bool { } c := auxIntToInt64(v_0.AuxInt) x := v_1 - if !(isUint64PowerOfTwo(^c) && uint64(^c) >= 1<<31) { + if !(isUnsignedPowerOfTwo(uint64(^c)) && uint64(^c) >= 1<<31) { continue } v.reset(OpAMD64BTRQconst) - v.AuxInt = int8ToAuxInt(int8(log64(^c))) + v.AuxInt = int8ToAuxInt(int8(log64u(uint64(^c)))) v.AddArg(x) return true } @@ -14431,8 +14431,8 @@ func rewriteValueAMD64_OpAMD64ORQ(v *Value) bool { break } // match: (ORQ (MOVQconst [c]) x) - // cond: isUint64PowerOfTwo(c) && uint64(c) >= 1<<31 - // result: (BTSQconst [int8(log64(c))] x) + // cond: isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31 + // result: (BTSQconst [int8(log64u(uint64(c)))] x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAMD64MOVQconst { @@ -14440,11 +14440,11 @@ func rewriteValueAMD64_OpAMD64ORQ(v *Value) bool { } c := auxIntToInt64(v_0.AuxInt) x := v_1 - if !(isUint64PowerOfTwo(c) && uint64(c) >= 1<<31) { + if !(isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31) { continue } v.reset(OpAMD64BTSQconst) - v.AuxInt = int8ToAuxInt(int8(log64(c))) + v.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v.AddArg(x) return true } @@ -17398,46 +17398,46 @@ func rewriteValueAMD64_OpAMD64SETEQ(v *Value) bool { break } // match: (SETEQ (TESTLconst [c] x)) - // cond: isUint32PowerOfTwo(int64(c)) - // result: (SETAE (BTLconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETAE (BTLconst [int8(log32u(uint32(c)))] x)) for { if v_0.Op != OpAMD64TESTLconst { break } c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint32PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint32(c))) { break } v.reset(OpAMD64SETAE) v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg(v0) return true } // match: (SETEQ (TESTQconst [c] x)) - // cond: isUint64PowerOfTwo(int64(c)) - // result: (SETAE (BTQconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAE (BTQconst [int8(log32u(uint32(c)))] x)) for { if v_0.Op != OpAMD64TESTQconst { break } c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint64PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint64(c))) { break } v.reset(OpAMD64SETAE) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg(v0) return true } // match: (SETEQ (TESTQ (MOVQconst [c]) x)) - // cond: isUint64PowerOfTwo(c) - // result: (SETAE (BTQconst [int8(log64(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAE (BTQconst [int8(log64u(uint64(c)))] x)) for { if v_0.Op != OpAMD64TESTQ { break @@ -17451,12 +17451,12 @@ func rewriteValueAMD64_OpAMD64SETEQ(v *Value) bool { } c := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 - if !(isUint64PowerOfTwo(c)) { + if !(isUnsignedPowerOfTwo(uint64(c))) { continue } v.reset(OpAMD64SETAE) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log64(c))) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v0.AddArg(x) v.AddArg(v0) return true @@ -17875,8 +17875,8 @@ func rewriteValueAMD64_OpAMD64SETEQstore(v *Value) bool { break } // match: (SETEQstore [off] {sym} ptr (TESTLconst [c] x) mem) - // cond: isUint32PowerOfTwo(int64(c)) - // result: (SETAEstore [off] {sym} ptr (BTLconst [int8(log32(c))] x) mem) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETAEstore [off] {sym} ptr (BTLconst [int8(log32u(uint32(c)))] x) mem) for { off := auxIntToInt32(v.AuxInt) sym := auxToSym(v.Aux) @@ -17887,21 +17887,21 @@ func rewriteValueAMD64_OpAMD64SETEQstore(v *Value) bool { c := auxIntToInt32(v_1.AuxInt) x := v_1.Args[0] mem := v_2 - if !(isUint32PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint32(c))) { break } v.reset(OpAMD64SETAEstore) v.AuxInt = int32ToAuxInt(off) v.Aux = symToAux(sym) v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg3(ptr, v0, mem) return true } // match: (SETEQstore [off] {sym} ptr (TESTQconst [c] x) mem) - // cond: isUint64PowerOfTwo(int64(c)) - // result: (SETAEstore [off] {sym} ptr (BTQconst [int8(log32(c))] x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAEstore [off] {sym} ptr (BTQconst [int8(log32u(uint32(c)))] x) mem) for { off := auxIntToInt32(v.AuxInt) sym := auxToSym(v.Aux) @@ -17912,21 +17912,21 @@ func rewriteValueAMD64_OpAMD64SETEQstore(v *Value) bool { c := auxIntToInt32(v_1.AuxInt) x := v_1.Args[0] mem := v_2 - if !(isUint64PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint64(c))) { break } v.reset(OpAMD64SETAEstore) v.AuxInt = int32ToAuxInt(off) v.Aux = symToAux(sym) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg3(ptr, v0, mem) return true } // match: (SETEQstore [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) - // cond: isUint64PowerOfTwo(c) - // result: (SETAEstore [off] {sym} ptr (BTQconst [int8(log64(c))] x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAEstore [off] {sym} ptr (BTQconst [int8(log64u(uint64(c)))] x) mem) for { off := auxIntToInt32(v.AuxInt) sym := auxToSym(v.Aux) @@ -17944,14 +17944,14 @@ func rewriteValueAMD64_OpAMD64SETEQstore(v *Value) bool { c := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 mem := v_2 - if !(isUint64PowerOfTwo(c)) { + if !(isUnsignedPowerOfTwo(uint64(c))) { continue } v.reset(OpAMD64SETAEstore) v.AuxInt = int32ToAuxInt(off) v.Aux = symToAux(sym) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log64(c))) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v0.AddArg(x) v.AddArg3(ptr, v0, mem) return true @@ -19444,46 +19444,46 @@ func rewriteValueAMD64_OpAMD64SETNE(v *Value) bool { break } // match: (SETNE (TESTLconst [c] x)) - // cond: isUint32PowerOfTwo(int64(c)) - // result: (SETB (BTLconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETB (BTLconst [int8(log32u(uint32(c)))] x)) for { if v_0.Op != OpAMD64TESTLconst { break } c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint32PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint32(c))) { break } v.reset(OpAMD64SETB) v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg(v0) return true } // match: (SETNE (TESTQconst [c] x)) - // cond: isUint64PowerOfTwo(int64(c)) - // result: (SETB (BTQconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETB (BTQconst [int8(log32u(uint32(c)))] x)) for { if v_0.Op != OpAMD64TESTQconst { break } c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint64PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint64(c))) { break } v.reset(OpAMD64SETB) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg(v0) return true } // match: (SETNE (TESTQ (MOVQconst [c]) x)) - // cond: isUint64PowerOfTwo(c) - // result: (SETB (BTQconst [int8(log64(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETB (BTQconst [int8(log64u(uint64(c)))] x)) for { if v_0.Op != OpAMD64TESTQ { break @@ -19497,12 +19497,12 @@ func rewriteValueAMD64_OpAMD64SETNE(v *Value) bool { } c := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 - if !(isUint64PowerOfTwo(c)) { + if !(isUnsignedPowerOfTwo(uint64(c))) { continue } v.reset(OpAMD64SETB) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log64(c))) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v0.AddArg(x) v.AddArg(v0) return true @@ -19921,8 +19921,8 @@ func rewriteValueAMD64_OpAMD64SETNEstore(v *Value) bool { break } // match: (SETNEstore [off] {sym} ptr (TESTLconst [c] x) mem) - // cond: isUint32PowerOfTwo(int64(c)) - // result: (SETBstore [off] {sym} ptr (BTLconst [int8(log32(c))] x) mem) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETBstore [off] {sym} ptr (BTLconst [int8(log32u(uint32(c)))] x) mem) for { off := auxIntToInt32(v.AuxInt) sym := auxToSym(v.Aux) @@ -19933,21 +19933,21 @@ func rewriteValueAMD64_OpAMD64SETNEstore(v *Value) bool { c := auxIntToInt32(v_1.AuxInt) x := v_1.Args[0] mem := v_2 - if !(isUint32PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint32(c))) { break } v.reset(OpAMD64SETBstore) v.AuxInt = int32ToAuxInt(off) v.Aux = symToAux(sym) v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg3(ptr, v0, mem) return true } // match: (SETNEstore [off] {sym} ptr (TESTQconst [c] x) mem) - // cond: isUint64PowerOfTwo(int64(c)) - // result: (SETBstore [off] {sym} ptr (BTQconst [int8(log32(c))] x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETBstore [off] {sym} ptr (BTQconst [int8(log32u(uint32(c)))] x) mem) for { off := auxIntToInt32(v.AuxInt) sym := auxToSym(v.Aux) @@ -19958,21 +19958,21 @@ func rewriteValueAMD64_OpAMD64SETNEstore(v *Value) bool { c := auxIntToInt32(v_1.AuxInt) x := v_1.Args[0] mem := v_2 - if !(isUint64PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint64(c))) { break } v.reset(OpAMD64SETBstore) v.AuxInt = int32ToAuxInt(off) v.Aux = symToAux(sym) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) v.AddArg3(ptr, v0, mem) return true } // match: (SETNEstore [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) - // cond: isUint64PowerOfTwo(c) - // result: (SETBstore [off] {sym} ptr (BTQconst [int8(log64(c))] x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETBstore [off] {sym} ptr (BTQconst [int8(log64u(uint64(c)))] x) mem) for { off := auxIntToInt32(v.AuxInt) sym := auxToSym(v.Aux) @@ -19990,14 +19990,14 @@ func rewriteValueAMD64_OpAMD64SETNEstore(v *Value) bool { c := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 mem := v_2 - if !(isUint64PowerOfTwo(c)) { + if !(isUnsignedPowerOfTwo(uint64(c))) { continue } v.reset(OpAMD64SETBstore) v.AuxInt = int32ToAuxInt(off) v.Aux = symToAux(sym) v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log64(c))) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v0.AddArg(x) v.AddArg3(ptr, v0, mem) return true @@ -23495,8 +23495,8 @@ func rewriteValueAMD64_OpAMD64XORQ(v *Value) bool { break } // match: (XORQ (MOVQconst [c]) x) - // cond: isUint64PowerOfTwo(c) && uint64(c) >= 1<<31 - // result: (BTCQconst [int8(log64(c))] x) + // cond: isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31 + // result: (BTCQconst [int8(log64u(uint64(c)))] x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAMD64MOVQconst { @@ -23504,11 +23504,11 @@ func rewriteValueAMD64_OpAMD64XORQ(v *Value) bool { } c := auxIntToInt64(v_0.AuxInt) x := v_1 - if !(isUint64PowerOfTwo(c) && uint64(c) >= 1<<31) { + if !(isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31) { continue } v.reset(OpAMD64BTCQconst) - v.AuxInt = int8ToAuxInt(int8(log64(c))) + v.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v.AddArg(x) return true } @@ -30148,40 +30148,40 @@ func rewriteBlockAMD64(b *Block) bool { break } // match: (EQ (TESTLconst [c] x)) - // cond: isUint32PowerOfTwo(int64(c)) - // result: (UGE (BTLconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (UGE (BTLconst [int8(log32u(uint32(c)))] x)) for b.Controls[0].Op == OpAMD64TESTLconst { v_0 := b.Controls[0] c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint32PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint32(c))) { break } v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) b.resetWithControl(BlockAMD64UGE, v0) return true } // match: (EQ (TESTQconst [c] x)) - // cond: isUint64PowerOfTwo(int64(c)) - // result: (UGE (BTQconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (UGE (BTQconst [int8(log32u(uint32(c)))] x)) for b.Controls[0].Op == OpAMD64TESTQconst { v_0 := b.Controls[0] c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint64PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint64(c))) { break } v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) b.resetWithControl(BlockAMD64UGE, v0) return true } // match: (EQ (TESTQ (MOVQconst [c]) x)) - // cond: isUint64PowerOfTwo(c) - // result: (UGE (BTQconst [int8(log64(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (UGE (BTQconst [int8(log64u(uint64(c)))] x)) for b.Controls[0].Op == OpAMD64TESTQ { v_0 := b.Controls[0] _ = v_0.Args[1] @@ -30193,11 +30193,11 @@ func rewriteBlockAMD64(b *Block) bool { } c := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 - if !(isUint64PowerOfTwo(c)) { + if !(isUnsignedPowerOfTwo(uint64(c))) { continue } v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log64(c))) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v0.AddArg(x) b.resetWithControl(BlockAMD64UGE, v0) return true @@ -31128,40 +31128,40 @@ func rewriteBlockAMD64(b *Block) bool { break } // match: (NE (TESTLconst [c] x)) - // cond: isUint32PowerOfTwo(int64(c)) - // result: (ULT (BTLconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (ULT (BTLconst [int8(log32u(uint32(c)))] x)) for b.Controls[0].Op == OpAMD64TESTLconst { v_0 := b.Controls[0] c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint32PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint32(c))) { break } v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) b.resetWithControl(BlockAMD64ULT, v0) return true } // match: (NE (TESTQconst [c] x)) - // cond: isUint64PowerOfTwo(int64(c)) - // result: (ULT (BTQconst [int8(log32(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (ULT (BTQconst [int8(log32u(uint32(c)))] x)) for b.Controls[0].Op == OpAMD64TESTQconst { v_0 := b.Controls[0] c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(isUint64PowerOfTwo(int64(c))) { + if !(isUnsignedPowerOfTwo(uint64(c))) { break } v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log32(c))) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) v0.AddArg(x) b.resetWithControl(BlockAMD64ULT, v0) return true } // match: (NE (TESTQ (MOVQconst [c]) x)) - // cond: isUint64PowerOfTwo(c) - // result: (ULT (BTQconst [int8(log64(c))] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (ULT (BTQconst [int8(log64u(uint64(c)))] x)) for b.Controls[0].Op == OpAMD64TESTQ { v_0 := b.Controls[0] _ = v_0.Args[1] @@ -31173,11 +31173,11 @@ func rewriteBlockAMD64(b *Block) bool { } c := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 - if !(isUint64PowerOfTwo(c)) { + if !(isUnsignedPowerOfTwo(uint64(c))) { continue } v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) - v0.AuxInt = int8ToAuxInt(int8(log64(c))) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) v0.AddArg(x) b.resetWithControl(BlockAMD64ULT, v0) return true -- 2.51.0