// Fold transfer of CA -> GPR -> CA. Note 2 uses when feeding into a chained Add64carry.
(Select1 (ADDCconst n:(ADDZEzero x) [-1])) && n.Uses <= 2 => x
(ADDE (MOVDconst [0]) y c) => (ADDZE y c)
+(ADDC x (MOVDconst [y])) && is16Bit(y) => (ADDCconst [y] x)
// Borrowing subtraction.
(Select0 (Sub64borrow x y c)) => (Select0 <typ.UInt64> (SUBE x y (Select1 <typ.UInt64> (SUBCconst c [0]))))
return true
case OpPPC64ADD:
return rewriteValuePPC64_OpPPC64ADD(v)
+ case OpPPC64ADDC:
+ return rewriteValuePPC64_OpPPC64ADDC(v)
case OpPPC64ADDE:
return rewriteValuePPC64_OpPPC64ADDE(v)
case OpPPC64ADDconst:
}
return false
}
+func rewriteValuePPC64_OpPPC64ADDC(v *Value) bool {
+ v_1 := v.Args[1]
+ v_0 := v.Args[0]
+ // match: (ADDC x (MOVDconst [y]))
+ // cond: is16Bit(y)
+ // result: (ADDCconst [y] x)
+ for {
+ for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
+ x := v_0
+ if v_1.Op != OpPPC64MOVDconst {
+ continue
+ }
+ y := auxIntToInt64(v_1.AuxInt)
+ if !(is16Bit(y)) {
+ continue
+ }
+ v.reset(OpPPC64ADDCconst)
+ v.AuxInt = int64ToAuxInt(y)
+ v.AddArg(x)
+ return true
+ }
+ break
+ }
+ return false
+}
func rewriteValuePPC64_OpPPC64ADDE(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
func foldConst(x, y uint64) uint64 {
// arm64: "ADDS\t[$]7",-"MOVD\t[$]7"
+ // ppc64x: "ADDC\t[$]7,"
d, b := bits.Add64(x, 7, 0)
return b & d
}