// zero upper bit of the register; no need to zero-extend
(MOVBUreg x:((Equal|NotEqual|LessThan|LessThanU|LessThanF|LessEqual|LessEqualU|LessEqualF|GreaterThan|GreaterThanU|GreaterThanF|GreaterEqual|GreaterEqualU|GreaterEqualF) _)) => (MOVDreg x)
+// Don't bother extending if we're not using the higher bits.
+(MOV(B|BU)reg x) && v.Type.Size() <= 1 => x
+(MOV(H|HU)reg x) && v.Type.Size() <= 2 => x
+(MOV(W|WU)reg x) && v.Type.Size() <= 4 => x
+
// omit unsign extension
(MOVWUreg x) && zeroUpper32Bits(x, 3) => x
v.AddArg(x)
return true
}
+ // match: (MOVBUreg x)
+ // cond: v.Type.Size() <= 1
+ // result: x
+ for {
+ x := v_0
+ if !(v.Type.Size() <= 1) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
// match: (MOVBUreg (SLLconst [lc] x))
// cond: lc >= 8
// result: (MOVDconst [0])
v.AuxInt = int64ToAuxInt(int64(int8(c)))
return true
}
+ // match: (MOVBreg x)
+ // cond: v.Type.Size() <= 1
+ // result: x
+ for {
+ x := v_0
+ if !(v.Type.Size() <= 1) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
// match: (MOVBreg <t> (ANDconst x [c]))
// cond: uint64(c) & uint64(0xffffffffffffff80) == 0
// result: (ANDconst <t> x [c])
v.AuxInt = int64ToAuxInt(int64(uint16(c)))
return true
}
+ // match: (MOVHUreg x)
+ // cond: v.Type.Size() <= 2
+ // result: x
+ for {
+ x := v_0
+ if !(v.Type.Size() <= 2) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
// match: (MOVHUreg (SLLconst [lc] x))
// cond: lc >= 16
// result: (MOVDconst [0])
v.AuxInt = int64ToAuxInt(int64(int16(c)))
return true
}
+ // match: (MOVHreg x)
+ // cond: v.Type.Size() <= 2
+ // result: x
+ for {
+ x := v_0
+ if !(v.Type.Size() <= 2) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
// match: (MOVHreg <t> (ANDconst x [c]))
// cond: uint64(c) & uint64(0xffffffffffff8000) == 0
// result: (ANDconst <t> x [c])
return true
}
// match: (MOVWUreg x)
+ // cond: v.Type.Size() <= 4
+ // result: x
+ for {
+ x := v_0
+ if !(v.Type.Size() <= 4) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
+ // match: (MOVWUreg x)
// cond: zeroUpper32Bits(x, 3)
// result: x
for {
v.AuxInt = int64ToAuxInt(int64(int32(c)))
return true
}
+ // match: (MOVWreg x)
+ // cond: v.Type.Size() <= 4
+ // result: x
+ for {
+ x := v_0
+ if !(v.Type.Size() <= 4) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
// match: (MOVWreg <t> (ANDconst x [c]))
// cond: uint64(c) & uint64(0xffffffff80000000) == 0
// result: (ANDconst <t> x [c])