File tree Expand file tree Collapse file tree 3 files changed +15
-21
lines changed
src/cmd/compile/internal/ssa Expand file tree Collapse file tree 3 files changed +15
-21
lines changed Original file line number Diff line number Diff line change 607
607
(Select0 (MULTU (MOVWconst [1]) _ )) => (MOVWconst [0])
608
608
(Select1 (MULTU (MOVWconst [-1]) x )) => (NEG <x.Type> x)
609
609
(Select0 (MULTU (MOVWconst [-1]) x )) => (CMOVZ (ADDconst <x.Type> [-1] x) (MOVWconst [0]) x)
610
- (Select1 (MULTU (MOVWconst [c]) x )) && isPowerOfTwo(int64( uint32(c))) => (SLLconst [int32(log2uint32(int64 (c)))] x)
611
- (Select0 (MULTU (MOVWconst [c]) x )) && isPowerOfTwo(int64( uint32(c))) => (SRLconst [int32(32-log2uint32(int64 (c)))] x)
610
+ (Select1 (MULTU (MOVWconst [c]) x )) && isUnsignedPowerOfTwo( uint32(c)) => (SLLconst [int32(log32u(uint32 (c)))] x)
611
+ (Select0 (MULTU (MOVWconst [c]) x )) && isUnsignedPowerOfTwo( uint32(c)) => (SRLconst [int32(32-log32u(uint32 (c)))] x)
612
612
613
613
(MUL (MOVWconst [0]) _ ) => (MOVWconst [0])
614
614
(MUL (MOVWconst [1]) x ) => x
615
615
(MUL (MOVWconst [-1]) x ) => (NEG x)
616
- (MUL (MOVWconst [c]) x ) && isPowerOfTwo(int64( uint32(c))) => (SLLconst [int32(log2uint32(int64 (c)))] x)
616
+ (MUL (MOVWconst [c]) x ) && isUnsignedPowerOfTwo( uint32(c)) => (SLLconst [int32(log32u(uint32 (c)))] x)
617
617
618
618
// generic simplifications
619
619
(ADD x (NEG y)) => (SUB x y)
Original file line number Diff line number Diff line change @@ -492,12 +492,6 @@ func log16u(n uint16) int64 { return int64(bits.Len16(n)) - 1 }
492
492
func log32u (n uint32 ) int64 { return int64 (bits .Len32 (n )) - 1 }
493
493
func log64u (n uint64 ) int64 { return int64 (bits .Len64 (n )) - 1 }
494
494
495
- // log2uint32 returns logarithm in base 2 of uint32(n), with log2(0) = -1.
496
- // Rounds down.
497
- func log2uint32 (n int64 ) int64 {
498
- return int64 (bits .Len32 (uint32 (n ))) - 1
499
- }
500
-
501
495
// isPowerOfTwoX functions report whether n is a power of 2.
502
496
func isPowerOfTwo [T int8 | int16 | int32 | int64 ](n T ) bool {
503
497
return n > 0 && n & (n - 1 ) == 0
You can’t perform that action at this time.
0 commit comments