// MOVWnop doesn't emit instruction, only for ensuring the type.
(MOVWreg x) && x.Uses == 1 => (MOVWnop x)
+// TODO: we should be able to get rid of MOVWnop all together.
+// But for now, this is enough to get rid of lots of them.
+(MOVWnop (MOVWconst [c])) => (MOVWconst [c])
+
// mul by constant
(MUL x (MOVWconst [c])) && int32(c) == -1 => (RSBconst [0] x)
(MUL _ (MOVWconst [0])) => (MOVWconst [0])
// MOVDnop doesn't emit instruction, only for ensuring the type.
(MOVDreg x) && x.Uses == 1 => (MOVDnop x)
+// TODO: we should be able to get rid of MOVDnop all together.
+// But for now, this is enough to get rid of lots of them.
+(MOVDnop (MOVDconst [c])) => (MOVDconst [c])
+
// fold constant into arithmatic ops
(ADD x (MOVDconst [c])) => (ADDconst [c] x)
(SUB x (MOVDconst [c])) => (SUBconst [c] x)
// MOVWnop doesn't emit instruction, only for ensuring the type.
(MOVWreg x) && x.Uses == 1 => (MOVWnop x)
+// TODO: we should be able to get rid of MOVWnop all together.
+// But for now, this is enough to get rid of lots of them.
+(MOVWnop (MOVWconst [c])) => (MOVWconst [c])
+
// fold constant into arithmatic ops
(ADD x (MOVWconst [c])) => (ADDconst [c] x)
(SUB x (MOVWconst [c])) => (SUBconst [c] x)
// MOVVnop doesn't emit instruction, only for ensuring the type.
(MOVVreg x) && x.Uses == 1 => (MOVVnop x)
+// TODO: we should be able to get rid of MOVVnop all together.
+// But for now, this is enough to get rid of lots of them.
+(MOVVnop (MOVVconst [c])) => (MOVVconst [c])
+
// fold constant into arithmatic ops
(ADDV x (MOVVconst [c])) && is32Bit(c) => (ADDVconst [c] x)
(SUBV x (MOVVconst [c])) && is32Bit(c) => (SUBVconst [c] x)
// MOVnop does not emit an instruction, only for ensuring the type.
(MOVDreg x) && x.Uses == 1 => (MOVDnop x)
+// TODO: we should be able to get rid of MOVDnop all together.
+// But for now, this is enough to get rid of lots of them.
+(MOVDnop (MOVDconst [c])) => (MOVDconst [c])
+
// Fold constant into immediate instructions where possible.
(ADD (MOVBconst [val]) x) => (ADDI [int64(val)] x)
(ADD (MOVHconst [val]) x) => (ADDI [int64(val)] x)
return rewriteValueARM_OpARMMOVWloadshiftRA(v)
case OpARMMOVWloadshiftRL:
return rewriteValueARM_OpARMMOVWloadshiftRL(v)
+ case OpARMMOVWnop:
+ return rewriteValueARM_OpARMMOVWnop(v)
case OpARMMOVWreg:
return rewriteValueARM_OpARMMOVWreg(v)
case OpARMMOVWstore:
}
return false
}
+func rewriteValueARM_OpARMMOVWnop(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (MOVWnop (MOVWconst [c]))
+ // result: (MOVWconst [c])
+ for {
+ if v_0.Op != OpARMMOVWconst {
+ break
+ }
+ c := auxIntToInt32(v_0.AuxInt)
+ v.reset(OpARMMOVWconst)
+ v.AuxInt = int32ToAuxInt(c)
+ return true
+ }
+ return false
+}
func rewriteValueARM_OpARMMOVWreg(v *Value) bool {
v_0 := v.Args[0]
// match: (MOVWreg x)
return rewriteValueARM64_OpARM64MOVDloadidx(v)
case OpARM64MOVDloadidx8:
return rewriteValueARM64_OpARM64MOVDloadidx8(v)
+ case OpARM64MOVDnop:
+ return rewriteValueARM64_OpARM64MOVDnop(v)
case OpARM64MOVDreg:
return rewriteValueARM64_OpARM64MOVDreg(v)
case OpARM64MOVDstore:
}
return false
}
+func rewriteValueARM64_OpARM64MOVDnop(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (MOVDnop (MOVDconst [c]))
+ // result: (MOVDconst [c])
+ for {
+ if v_0.Op != OpARM64MOVDconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ v.reset(OpARM64MOVDconst)
+ v.AuxInt = int64ToAuxInt(c)
+ return true
+ }
+ return false
+}
func rewriteValueARM64_OpARM64MOVDreg(v *Value) bool {
v_0 := v.Args[0]
// match: (MOVDreg x)
return rewriteValueMIPS_OpMIPSMOVHstorezero(v)
case OpMIPSMOVWload:
return rewriteValueMIPS_OpMIPSMOVWload(v)
+ case OpMIPSMOVWnop:
+ return rewriteValueMIPS_OpMIPSMOVWnop(v)
case OpMIPSMOVWreg:
return rewriteValueMIPS_OpMIPSMOVWreg(v)
case OpMIPSMOVWstore:
}
return false
}
+func rewriteValueMIPS_OpMIPSMOVWnop(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (MOVWnop (MOVWconst [c]))
+ // result: (MOVWconst [c])
+ for {
+ if v_0.Op != OpMIPSMOVWconst {
+ break
+ }
+ c := auxIntToInt32(v_0.AuxInt)
+ v.reset(OpMIPSMOVWconst)
+ v.AuxInt = int32ToAuxInt(c)
+ return true
+ }
+ return false
+}
func rewriteValueMIPS_OpMIPSMOVWreg(v *Value) bool {
v_0 := v.Args[0]
// match: (MOVWreg x)
return rewriteValueMIPS64_OpMIPS64MOVHstorezero(v)
case OpMIPS64MOVVload:
return rewriteValueMIPS64_OpMIPS64MOVVload(v)
+ case OpMIPS64MOVVnop:
+ return rewriteValueMIPS64_OpMIPS64MOVVnop(v)
case OpMIPS64MOVVreg:
return rewriteValueMIPS64_OpMIPS64MOVVreg(v)
case OpMIPS64MOVVstore:
}
return false
}
+func rewriteValueMIPS64_OpMIPS64MOVVnop(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (MOVVnop (MOVVconst [c]))
+ // result: (MOVVconst [c])
+ for {
+ if v_0.Op != OpMIPS64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ v.reset(OpMIPS64MOVVconst)
+ v.AuxInt = int64ToAuxInt(c)
+ return true
+ }
+ return false
+}
func rewriteValueMIPS64_OpMIPS64MOVVreg(v *Value) bool {
v_0 := v.Args[0]
// match: (MOVVreg x)
return rewriteValueRISCV64_OpRISCV64MOVDconst(v)
case OpRISCV64MOVDload:
return rewriteValueRISCV64_OpRISCV64MOVDload(v)
+ case OpRISCV64MOVDnop:
+ return rewriteValueRISCV64_OpRISCV64MOVDnop(v)
case OpRISCV64MOVDreg:
return rewriteValueRISCV64_OpRISCV64MOVDreg(v)
case OpRISCV64MOVDstore:
}
return false
}
+func rewriteValueRISCV64_OpRISCV64MOVDnop(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (MOVDnop (MOVDconst [c]))
+ // result: (MOVDconst [c])
+ for {
+ if v_0.Op != OpRISCV64MOVDconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ v.reset(OpRISCV64MOVDconst)
+ v.AuxInt = int64ToAuxInt(c)
+ return true
+ }
+ return false
+}
func rewriteValueRISCV64_OpRISCV64MOVDreg(v *Value) bool {
v_0 := v.Args[0]
// match: (MOVDreg x)