(Hmul32 x y) => (SRAVconst (MULV (SignExt32to64 x) (SignExt32to64 y)) [32])
(Hmul32u x y) => (SRLVconst (MULV (ZeroExt32to64 x) (ZeroExt32to64 y)) [32])
-(Div64 x y) => (Select1 (DIVV x y))
-(Div64u x y) => (Select1 (DIVVU x y))
-(Div32 x y) => (Select1 (DIVV (SignExt32to64 x) (SignExt32to64 y)))
-(Div32u x y) => (Select1 (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y)))
-(Div16 x y) => (Select1 (DIVV (SignExt16to64 x) (SignExt16to64 y)))
-(Div16u x y) => (Select1 (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y)))
-(Div8 x y) => (Select1 (DIVV (SignExt8to64 x) (SignExt8to64 y)))
-(Div8u x y) => (Select1 (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y)))
+(Div64 x y) => (DIVV x y)
+(Div64u ...) => (DIVVU ...)
+(Div32 x y) => (DIVV (SignExt32to64 x) (SignExt32to64 y))
+(Div32u x y) => (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y))
+(Div16 x y) => (DIVV (SignExt16to64 x) (SignExt16to64 y))
+(Div16u x y) => (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y))
+(Div8 x y) => (DIVV (SignExt8to64 x) (SignExt8to64 y))
+(Div8u x y) => (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y))
(Div(32|64)F ...) => (DIV(F|D) ...)
-(Mod64 x y) => (Select0 (DIVV x y))
-(Mod64u x y) => (Select0 (DIVVU x y))
-(Mod32 x y) => (Select0 (DIVV (SignExt32to64 x) (SignExt32to64 y)))
-(Mod32u x y) => (Select0 (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y)))
-(Mod16 x y) => (Select0 (DIVV (SignExt16to64 x) (SignExt16to64 y)))
-(Mod16u x y) => (Select0 (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y)))
-(Mod8 x y) => (Select0 (DIVV (SignExt8to64 x) (SignExt8to64 y)))
-(Mod8u x y) => (Select0 (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y)))
+(Mod64 x y) => (REMV x y)
+(Mod64u ...) => (REMVU ...)
+(Mod32 x y) => (REMV (SignExt32to64 x) (SignExt32to64 y))
+(Mod32u x y) => (REMVU (ZeroExt32to64 x) (ZeroExt32to64 y))
+(Mod16 x y) => (REMV (SignExt16to64 x) (SignExt16to64 y))
+(Mod16u x y) => (REMVU (ZeroExt16to64 x) (ZeroExt16to64 y))
+(Mod8 x y) => (REMV (SignExt8to64 x) (SignExt8to64 y))
+(Mod8u x y) => (REMVU (ZeroExt8to64 x) (ZeroExt8to64 y))
(Select0 <t> (Add64carry x y c)) => (ADDV (ADDV <t> x y) c)
(Select1 <t> (Add64carry x y c)) =>
(MULV x (MOVVconst [c])) && isPowerOfTwo64(c) => (SLLVconst [log64(c)] x)
// div by constant
-(Select1 (DIVVU x (MOVVconst [1]))) => x
-(Select1 (DIVVU x (MOVVconst [c]))) && isPowerOfTwo64(c) => (SRLVconst [log64(c)] x)
-(Select0 (DIVVU _ (MOVVconst [1]))) => (MOVVconst [0]) // mod
-(Select0 (DIVVU x (MOVVconst [c]))) && isPowerOfTwo64(c) => (ANDconst [c-1] x) // mod
+(DIVVU x (MOVVconst [1])) => x
+(DIVVU x (MOVVconst [c])) && isPowerOfTwo64(c) => (SRLVconst [log64(c)] x)
+(REMVU _ (MOVVconst [1])) => (MOVVconst [0]) // mod
+(REMVU x (MOVVconst [c])) && isPowerOfTwo64(c) => (ANDconst [c-1] x) // mod
// generic simplifications
(ADDV x (NEGV y)) => (SUBV x y)
(SRLVconst [c] (MOVVconst [d])) => (MOVVconst [int64(uint64(d)>>uint64(c))])
(SRAVconst [c] (MOVVconst [d])) => (MOVVconst [d>>uint64(c)])
(MULV (MOVVconst [c]) (MOVVconst [d])) => (MOVVconst [c*d])
-(Select1 (DIVV (MOVVconst [c]) (MOVVconst [d]))) && d != 0 => (MOVVconst [c/d])
-(Select1 (DIVVU (MOVVconst [c]) (MOVVconst [d]))) && d != 0 => (MOVVconst [int64(uint64(c)/uint64(d))])
-(Select0 (DIVV (MOVVconst [c]) (MOVVconst [d]))) && d != 0 => (MOVVconst [c%d]) // mod
-(Select0 (DIVVU (MOVVconst [c]) (MOVVconst [d]))) && d != 0 => (MOVVconst [int64(uint64(c)%uint64(d))]) // mod
+(DIVV (MOVVconst [c]) (MOVVconst [d])) && d != 0 => (MOVVconst [c/d])
+(DIVVU (MOVVconst [c]) (MOVVconst [d])) && d != 0 => (MOVVconst [int64(uint64(c)/uint64(d))])
+(REMV (MOVVconst [c]) (MOVVconst [d])) && d != 0 => (MOVVconst [c%d]) // mod
+(REMVU (MOVVconst [c]) (MOVVconst [d])) && d != 0 => (MOVVconst [int64(uint64(c)%uint64(d))]) // mod
(ANDconst [c] (MOVVconst [d])) => (MOVVconst [c&d])
(ANDconst [c] (ANDconst [d] x)) => (ANDconst [c&d] x)
(ORconst [c] (MOVVconst [d])) => (MOVVconst [c|d])
v.Op = OpLOONG64DIVD
return true
case OpDiv64u:
- return rewriteValueLOONG64_OpDiv64u(v)
+ v.Op = OpLOONG64DIVVU
+ return true
case OpDiv8:
return rewriteValueLOONG64_OpDiv8(v)
case OpDiv8u:
return rewriteValueLOONG64_OpLOONG64AND(v)
case OpLOONG64ANDconst:
return rewriteValueLOONG64_OpLOONG64ANDconst(v)
+ case OpLOONG64DIVV:
+ return rewriteValueLOONG64_OpLOONG64DIVV(v)
+ case OpLOONG64DIVVU:
+ return rewriteValueLOONG64_OpLOONG64DIVVU(v)
case OpLOONG64LoweredAtomicAdd32:
return rewriteValueLOONG64_OpLOONG64LoweredAtomicAdd32(v)
case OpLOONG64LoweredAtomicAdd64:
return rewriteValueLOONG64_OpLOONG64OR(v)
case OpLOONG64ORconst:
return rewriteValueLOONG64_OpLOONG64ORconst(v)
+ case OpLOONG64REMV:
+ return rewriteValueLOONG64_OpLOONG64REMV(v)
+ case OpLOONG64REMVU:
+ return rewriteValueLOONG64_OpLOONG64REMVU(v)
case OpLOONG64ROTR:
return rewriteValueLOONG64_OpLOONG64ROTR(v)
case OpLOONG64ROTRV:
case OpMod64:
return rewriteValueLOONG64_OpMod64(v)
case OpMod64u:
- return rewriteValueLOONG64_OpMod64u(v)
+ v.Op = OpLOONG64REMVU
+ return true
case OpMod8:
return rewriteValueLOONG64_OpMod8(v)
case OpMod8u:
b := v.Block
typ := &b.Func.Config.Types
// match: (Div16 x y)
- // result: (Select1 (DIVV (SignExt16to64 x) (SignExt16to64 y)))
+ // result: (DIVV (SignExt16to64 x) (SignExt16to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
+ v.reset(OpLOONG64DIVV)
+ v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Div16u x y)
- // result: (Select1 (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y)))
+ // result: (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
+ v.reset(OpLOONG64DIVVU)
+ v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Div32 x y)
- // result: (Select1 (DIVV (SignExt32to64 x) (SignExt32to64 y)))
+ // result: (DIVV (SignExt32to64 x) (SignExt32to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
+ v.reset(OpLOONG64DIVV)
+ v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Div32u x y)
- // result: (Select1 (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y)))
+ // result: (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
+ v.reset(OpLOONG64DIVVU)
+ v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
func rewriteValueLOONG64_OpDiv64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
- b := v.Block
- typ := &b.Func.Config.Types
// match: (Div64 x y)
- // result: (Select1 (DIVV x y))
- for {
- x := v_0
- y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
- v0.AddArg2(x, y)
- v.AddArg(v0)
- return true
- }
-}
-func rewriteValueLOONG64_OpDiv64u(v *Value) bool {
- v_1 := v.Args[1]
- v_0 := v.Args[0]
- b := v.Block
- typ := &b.Func.Config.Types
- // match: (Div64u x y)
- // result: (Select1 (DIVVU x y))
+ // result: (DIVV x y)
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
- v0.AddArg2(x, y)
- v.AddArg(v0)
+ v.reset(OpLOONG64DIVV)
+ v.AddArg2(x, y)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Div8 x y)
- // result: (Select1 (DIVV (SignExt8to64 x) (SignExt8to64 y)))
+ // result: (DIVV (SignExt8to64 x) (SignExt8to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
+ v.reset(OpLOONG64DIVV)
+ v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Div8u x y)
- // result: (Select1 (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y)))
+ // result: (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect1)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
+ v.reset(OpLOONG64DIVVU)
+ v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
}
return false
}
+func rewriteValueLOONG64_OpLOONG64DIVV(v *Value) bool {
+ v_1 := v.Args[1]
+ v_0 := v.Args[0]
+ // match: (DIVV (MOVVconst [c]) (MOVVconst [d]))
+ // cond: d != 0
+ // result: (MOVVconst [c/d])
+ for {
+ if v_0.Op != OpLOONG64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ if v_1.Op != OpLOONG64MOVVconst {
+ break
+ }
+ d := auxIntToInt64(v_1.AuxInt)
+ if !(d != 0) {
+ break
+ }
+ v.reset(OpLOONG64MOVVconst)
+ v.AuxInt = int64ToAuxInt(c / d)
+ return true
+ }
+ return false
+}
+func rewriteValueLOONG64_OpLOONG64DIVVU(v *Value) bool {
+ v_1 := v.Args[1]
+ v_0 := v.Args[0]
+ // match: (DIVVU x (MOVVconst [1]))
+ // result: x
+ for {
+ x := v_0
+ if v_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_1.AuxInt) != 1 {
+ break
+ }
+ v.copyOf(x)
+ return true
+ }
+ // match: (DIVVU x (MOVVconst [c]))
+ // cond: isPowerOfTwo64(c)
+ // result: (SRLVconst [log64(c)] x)
+ for {
+ x := v_0
+ if v_1.Op != OpLOONG64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_1.AuxInt)
+ if !(isPowerOfTwo64(c)) {
+ break
+ }
+ v.reset(OpLOONG64SRLVconst)
+ v.AuxInt = int64ToAuxInt(log64(c))
+ v.AddArg(x)
+ return true
+ }
+ // match: (DIVVU (MOVVconst [c]) (MOVVconst [d]))
+ // cond: d != 0
+ // result: (MOVVconst [int64(uint64(c)/uint64(d))])
+ for {
+ if v_0.Op != OpLOONG64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ if v_1.Op != OpLOONG64MOVVconst {
+ break
+ }
+ d := auxIntToInt64(v_1.AuxInt)
+ if !(d != 0) {
+ break
+ }
+ v.reset(OpLOONG64MOVVconst)
+ v.AuxInt = int64ToAuxInt(int64(uint64(c) / uint64(d)))
+ return true
+ }
+ return false
+}
func rewriteValueLOONG64_OpLOONG64LoweredAtomicAdd32(v *Value) bool {
v_2 := v.Args[2]
v_1 := v.Args[1]
}
return false
}
+func rewriteValueLOONG64_OpLOONG64REMV(v *Value) bool {
+ v_1 := v.Args[1]
+ v_0 := v.Args[0]
+ // match: (REMV (MOVVconst [c]) (MOVVconst [d]))
+ // cond: d != 0
+ // result: (MOVVconst [c%d])
+ for {
+ if v_0.Op != OpLOONG64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ if v_1.Op != OpLOONG64MOVVconst {
+ break
+ }
+ d := auxIntToInt64(v_1.AuxInt)
+ if !(d != 0) {
+ break
+ }
+ v.reset(OpLOONG64MOVVconst)
+ v.AuxInt = int64ToAuxInt(c % d)
+ return true
+ }
+ return false
+}
+func rewriteValueLOONG64_OpLOONG64REMVU(v *Value) bool {
+ v_1 := v.Args[1]
+ v_0 := v.Args[0]
+ // match: (REMVU _ (MOVVconst [1]))
+ // result: (MOVVconst [0])
+ for {
+ if v_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_1.AuxInt) != 1 {
+ break
+ }
+ v.reset(OpLOONG64MOVVconst)
+ v.AuxInt = int64ToAuxInt(0)
+ return true
+ }
+ // match: (REMVU x (MOVVconst [c]))
+ // cond: isPowerOfTwo64(c)
+ // result: (ANDconst [c-1] x)
+ for {
+ x := v_0
+ if v_1.Op != OpLOONG64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_1.AuxInt)
+ if !(isPowerOfTwo64(c)) {
+ break
+ }
+ v.reset(OpLOONG64ANDconst)
+ v.AuxInt = int64ToAuxInt(c - 1)
+ v.AddArg(x)
+ return true
+ }
+ // match: (REMVU (MOVVconst [c]) (MOVVconst [d]))
+ // cond: d != 0
+ // result: (MOVVconst [int64(uint64(c)%uint64(d))])
+ for {
+ if v_0.Op != OpLOONG64MOVVconst {
+ break
+ }
+ c := auxIntToInt64(v_0.AuxInt)
+ if v_1.Op != OpLOONG64MOVVconst {
+ break
+ }
+ d := auxIntToInt64(v_1.AuxInt)
+ if !(d != 0) {
+ break
+ }
+ v.reset(OpLOONG64MOVVconst)
+ v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d)))
+ return true
+ }
+ return false
+}
func rewriteValueLOONG64_OpLOONG64ROTR(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod16 x y)
- // result: (Select0 (DIVV (SignExt16to64 x) (SignExt16to64 y)))
+ // result: (REMV (SignExt16to64 x) (SignExt16to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
+ v.reset(OpLOONG64REMV)
+ v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod16u x y)
- // result: (Select0 (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y)))
+ // result: (REMVU (ZeroExt16to64 x) (ZeroExt16to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
+ v.reset(OpLOONG64REMVU)
+ v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod32 x y)
- // result: (Select0 (DIVV (SignExt32to64 x) (SignExt32to64 y)))
+ // result: (REMV (SignExt32to64 x) (SignExt32to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
+ v.reset(OpLOONG64REMV)
+ v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod32u x y)
- // result: (Select0 (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y)))
+ // result: (REMVU (ZeroExt32to64 x) (ZeroExt32to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
+ v.reset(OpLOONG64REMVU)
+ v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
func rewriteValueLOONG64_OpMod64(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
- b := v.Block
- typ := &b.Func.Config.Types
// match: (Mod64 x y)
- // result: (Select0 (DIVV x y))
- for {
- x := v_0
- y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
- v0.AddArg2(x, y)
- v.AddArg(v0)
- return true
- }
-}
-func rewriteValueLOONG64_OpMod64u(v *Value) bool {
- v_1 := v.Args[1]
- v_0 := v.Args[0]
- b := v.Block
- typ := &b.Func.Config.Types
- // match: (Mod64u x y)
- // result: (Select0 (DIVVU x y))
+ // result: (REMV x y)
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
- v0.AddArg2(x, y)
- v.AddArg(v0)
+ v.reset(OpLOONG64REMV)
+ v.AddArg2(x, y)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod8 x y)
- // result: (Select0 (DIVV (SignExt8to64 x) (SignExt8to64 y)))
+ // result: (REMV (SignExt8to64 x) (SignExt8to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVV, types.NewTuple(typ.Int64, typ.Int64))
+ v.reset(OpLOONG64REMV)
+ v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
b := v.Block
typ := &b.Func.Config.Types
// match: (Mod8u x y)
- // result: (Select0 (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y)))
+ // result: (REMVU (ZeroExt8to64 x) (ZeroExt8to64 y))
for {
x := v_0
y := v_1
- v.reset(OpSelect0)
- v0 := b.NewValue0(v.Pos, OpLOONG64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64))
+ v.reset(OpLOONG64REMVU)
+ v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64)
+ v0.AddArg(x)
v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64)
- v1.AddArg(x)
- v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64)
- v2.AddArg(y)
- v0.AddArg2(v1, v2)
- v.AddArg(v0)
+ v1.AddArg(y)
+ v.AddArg2(v0, v1)
return true
}
}
v.AddArg2(v0, c)
return true
}
- // match: (Select0 (DIVVU _ (MOVVconst [1])))
- // result: (MOVVconst [0])
- for {
- if v_0.Op != OpLOONG64DIVVU {
- break
- }
- _ = v_0.Args[1]
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 1 {
- break
- }
- v.reset(OpLOONG64MOVVconst)
- v.AuxInt = int64ToAuxInt(0)
- return true
- }
- // match: (Select0 (DIVVU x (MOVVconst [c])))
- // cond: isPowerOfTwo64(c)
- // result: (ANDconst [c-1] x)
- for {
- if v_0.Op != OpLOONG64DIVVU {
- break
- }
- _ = v_0.Args[1]
- x := v_0.Args[0]
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst {
- break
- }
- c := auxIntToInt64(v_0_1.AuxInt)
- if !(isPowerOfTwo64(c)) {
- break
- }
- v.reset(OpLOONG64ANDconst)
- v.AuxInt = int64ToAuxInt(c - 1)
- v.AddArg(x)
- return true
- }
- // match: (Select0 (DIVV (MOVVconst [c]) (MOVVconst [d])))
- // cond: d != 0
- // result: (MOVVconst [c%d])
- for {
- if v_0.Op != OpLOONG64DIVV {
- break
- }
- _ = v_0.Args[1]
- v_0_0 := v_0.Args[0]
- if v_0_0.Op != OpLOONG64MOVVconst {
- break
- }
- c := auxIntToInt64(v_0_0.AuxInt)
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst {
- break
- }
- d := auxIntToInt64(v_0_1.AuxInt)
- if !(d != 0) {
- break
- }
- v.reset(OpLOONG64MOVVconst)
- v.AuxInt = int64ToAuxInt(c % d)
- return true
- }
- // match: (Select0 (DIVVU (MOVVconst [c]) (MOVVconst [d])))
- // cond: d != 0
- // result: (MOVVconst [int64(uint64(c)%uint64(d))])
- for {
- if v_0.Op != OpLOONG64DIVVU {
- break
- }
- _ = v_0.Args[1]
- v_0_0 := v_0.Args[0]
- if v_0_0.Op != OpLOONG64MOVVconst {
- break
- }
- c := auxIntToInt64(v_0_0.AuxInt)
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst {
- break
- }
- d := auxIntToInt64(v_0_1.AuxInt)
- if !(d != 0) {
- break
- }
- v.reset(OpLOONG64MOVVconst)
- v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d)))
- return true
- }
return false
}
func rewriteValueLOONG64_OpSelect1(v *Value) bool {
v.AddArg2(v0, v2)
return true
}
- // match: (Select1 (DIVVU x (MOVVconst [1])))
- // result: x
- for {
- if v_0.Op != OpLOONG64DIVVU {
- break
- }
- _ = v_0.Args[1]
- x := v_0.Args[0]
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 1 {
- break
- }
- v.copyOf(x)
- return true
- }
- // match: (Select1 (DIVVU x (MOVVconst [c])))
- // cond: isPowerOfTwo64(c)
- // result: (SRLVconst [log64(c)] x)
- for {
- if v_0.Op != OpLOONG64DIVVU {
- break
- }
- _ = v_0.Args[1]
- x := v_0.Args[0]
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst {
- break
- }
- c := auxIntToInt64(v_0_1.AuxInt)
- if !(isPowerOfTwo64(c)) {
- break
- }
- v.reset(OpLOONG64SRLVconst)
- v.AuxInt = int64ToAuxInt(log64(c))
- v.AddArg(x)
- return true
- }
- // match: (Select1 (DIVV (MOVVconst [c]) (MOVVconst [d])))
- // cond: d != 0
- // result: (MOVVconst [c/d])
- for {
- if v_0.Op != OpLOONG64DIVV {
- break
- }
- _ = v_0.Args[1]
- v_0_0 := v_0.Args[0]
- if v_0_0.Op != OpLOONG64MOVVconst {
- break
- }
- c := auxIntToInt64(v_0_0.AuxInt)
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst {
- break
- }
- d := auxIntToInt64(v_0_1.AuxInt)
- if !(d != 0) {
- break
- }
- v.reset(OpLOONG64MOVVconst)
- v.AuxInt = int64ToAuxInt(c / d)
- return true
- }
- // match: (Select1 (DIVVU (MOVVconst [c]) (MOVVconst [d])))
- // cond: d != 0
- // result: (MOVVconst [int64(uint64(c)/uint64(d))])
- for {
- if v_0.Op != OpLOONG64DIVVU {
- break
- }
- _ = v_0.Args[1]
- v_0_0 := v_0.Args[0]
- if v_0_0.Op != OpLOONG64MOVVconst {
- break
- }
- c := auxIntToInt64(v_0_0.AuxInt)
- v_0_1 := v_0.Args[1]
- if v_0_1.Op != OpLOONG64MOVVconst {
- break
- }
- d := auxIntToInt64(v_0_1.AuxInt)
- if !(d != 0) {
- break
- }
- v.reset(OpLOONG64MOVVconst)
- v.AuxInt = int64ToAuxInt(int64(uint64(c) / uint64(d)))
- return true
- }
return false
}
func rewriteValueLOONG64_OpSlicemask(v *Value) bool {