File tree Expand file tree Collapse file tree 3 files changed +32
-27
lines changed
src/cmd/compile/internal/ssa Expand file tree Collapse file tree 3 files changed +32
-27
lines changed Original file line number Diff line number Diff line change 1293
1293
(Const64 <typ.UInt64> [63])))
1294
1294
1295
1295
// Unsigned mod by power of 2 constant.
1296
- (Mod8u <t> n (Const8 [c])) && isPowerOfTwo(c) => (And8 n (Const8 <t> [c-1]))
1297
- (Mod16u <t> n (Const16 [c])) && isPowerOfTwo(c) => (And16 n (Const16 <t> [c-1]))
1298
- (Mod32u <t> n (Const32 [c])) && isPowerOfTwo(c) => (And32 n (Const32 <t> [c-1]))
1299
- (Mod64u <t> n (Const64 [c])) && isPowerOfTwo(c) => (And64 n (Const64 <t> [c-1]))
1300
- (Mod64u <t> n (Const64 [-1<<63])) => (And64 n (Const64 <t> [1<<63-1]))
1296
+ (Mod8u <t> n (Const8 [c])) && isUnsignedPowerOfTwo(uint8(c)) => (And8 n (Const8 <t> [c-1]))
1297
+ (Mod16u <t> n (Const16 [c])) && isUnsignedPowerOfTwo(uint16(c)) => (And16 n (Const16 <t> [c-1]))
1298
+ (Mod32u <t> n (Const32 [c])) && isUnsignedPowerOfTwo(uint32(c)) => (And32 n (Const32 <t> [c-1]))
1299
+ (Mod64u <t> n (Const64 [c])) && isUnsignedPowerOfTwo(uint64(c)) => (And64 n (Const64 <t> [c-1]))
1301
1300
1302
1301
// Signed non-negative mod by power of 2 constant.
1303
1302
(Mod8 <t> n (Const8 [c])) && isNonNegative(n) && isPowerOfTwo(c) => (And8 n (Const8 <t> [c-1]))
Original file line number Diff line number Diff line change @@ -25,3 +25,23 @@ func divUint8(b uint8) uint8 {
25
25
// amd64:"SHRB [$]7, AL"
26
26
return b / 128
27
27
}
28
+
29
+ func modUint64 (b uint64 ) uint64 {
30
+ // amd64:"BTRQ [$]63, AX"
31
+ return b % 9223372036854775808
32
+ }
33
+
34
+ func modUint32 (b uint32 ) uint32 {
35
+ // amd64:"ANDL [$]2147483647, AX"
36
+ return b % 2147483648
37
+ }
38
+
39
+ func modUint16 (b uint16 ) uint16 {
40
+ // amd64:"ANDL [$]32767, AX"
41
+ return b % 32768
42
+ }
43
+
44
+ func modUint8 (b uint8 ) uint8 {
45
+ // amd64:"ANDL [$]127, AX"
46
+ return b % 128
47
+ }
You can’t perform that action at this time.
0 commit comments