(MOVBUreg (ANDconst [c] x)) => (ANDconst [c&0xff] x)
+// Avoid extending when already sufficiently masked.
+(MOVBreg x:(ANDconst [c] y)) && c >= 0 && int64(int8(c)) == c => x
+(MOVHreg x:(ANDconst [c] y)) && c >= 0 && int64(int16(c)) == c => x
+(MOVWreg x:(ANDconst [c] y)) && c >= 0 && int64(int32(c)) == c => x
+(MOVBUreg x:(ANDconst [c] y)) && c >= 0 && int64(uint8(c)) == c => x
+(MOVHUreg x:(ANDconst [c] y)) && c >= 0 && int64(uint16(c)) == c => x
+(MOVWUreg x:(ANDconst [c] y)) && c >= 0 && int64(uint32(c)) == c => x
+
// Prefetch instructions (hint specified using aux field)
// For PRELD{,X} A value of hint indicates:
// hint=0 is defined as load prefetch to L1-cache
v.AddArg(x)
return true
}
+ // match: (MOVBUreg x:(ANDconst [c] y))
+ // cond: c >= 0 && int64(uint8(c)) == c
+ // result: x
+ for {
+ x := v_0
+ if x.Op != OpLOONG64ANDconst {
+ break
+ }
+ c := auxIntToInt64(x.AuxInt)
+ if !(c >= 0 && int64(uint8(c)) == c) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
return false
}
func rewriteValueLOONG64_OpLOONG64MOVBload(v *Value) bool {
v.AuxInt = int64ToAuxInt(int64(int8(c)))
return true
}
+ // match: (MOVBreg x:(ANDconst [c] y))
+ // cond: c >= 0 && int64(int8(c)) == c
+ // result: x
+ for {
+ x := v_0
+ if x.Op != OpLOONG64ANDconst {
+ break
+ }
+ c := auxIntToInt64(x.AuxInt)
+ if !(c >= 0 && int64(int8(c)) == c) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
return false
}
func rewriteValueLOONG64_OpLOONG64MOVBstore(v *Value) bool {
v.AuxInt = int64ToAuxInt(int64(uint16(c)))
return true
}
+ // match: (MOVHUreg x:(ANDconst [c] y))
+ // cond: c >= 0 && int64(uint16(c)) == c
+ // result: x
+ for {
+ x := v_0
+ if x.Op != OpLOONG64ANDconst {
+ break
+ }
+ c := auxIntToInt64(x.AuxInt)
+ if !(c >= 0 && int64(uint16(c)) == c) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
return false
}
func rewriteValueLOONG64_OpLOONG64MOVHload(v *Value) bool {
v.AuxInt = int64ToAuxInt(int64(int16(c)))
return true
}
+ // match: (MOVHreg x:(ANDconst [c] y))
+ // cond: c >= 0 && int64(int16(c)) == c
+ // result: x
+ for {
+ x := v_0
+ if x.Op != OpLOONG64ANDconst {
+ break
+ }
+ c := auxIntToInt64(x.AuxInt)
+ if !(c >= 0 && int64(int16(c)) == c) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
return false
}
func rewriteValueLOONG64_OpLOONG64MOVHstore(v *Value) bool {
v.AuxInt = int64ToAuxInt(int64(uint32(c)))
return true
}
+ // match: (MOVWUreg x:(ANDconst [c] y))
+ // cond: c >= 0 && int64(uint32(c)) == c
+ // result: x
+ for {
+ x := v_0
+ if x.Op != OpLOONG64ANDconst {
+ break
+ }
+ c := auxIntToInt64(x.AuxInt)
+ if !(c >= 0 && int64(uint32(c)) == c) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
return false
}
func rewriteValueLOONG64_OpLOONG64MOVWload(v *Value) bool {
v.AuxInt = int64ToAuxInt(int64(int32(c)))
return true
}
+ // match: (MOVWreg x:(ANDconst [c] y))
+ // cond: c >= 0 && int64(int32(c)) == c
+ // result: x
+ for {
+ x := v_0
+ if x.Op != OpLOONG64ANDconst {
+ break
+ }
+ c := auxIntToInt64(x.AuxInt)
+ if !(c >= 0 && int64(int32(c)) == c) {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
return false
}
func rewriteValueLOONG64_OpLOONG64MOVWstore(v *Value) bool {