}
func rewriteValue386_Op386ROLBconst(v *Value) bool {
v_0 := v.Args[0]
- // match: (ROLBconst [c] (ROLBconst [d] x))
- // result: (ROLBconst [(c+d)& 7] x)
- for {
- c := auxIntToInt8(v.AuxInt)
- if v_0.Op != Op386ROLBconst {
- break
- }
- d := auxIntToInt8(v_0.AuxInt)
- x := v_0.Args[0]
- v.reset(Op386ROLBconst)
- v.AuxInt = int8ToAuxInt((c + d) & 7)
- v.AddArg(x)
- return true
- }
// match: (ROLBconst [0] x)
// result: x
for {
}
func rewriteValue386_Op386ROLLconst(v *Value) bool {
v_0 := v.Args[0]
- // match: (ROLLconst [c] (ROLLconst [d] x))
- // result: (ROLLconst [(c+d)&31] x)
- for {
- c := auxIntToInt32(v.AuxInt)
- if v_0.Op != Op386ROLLconst {
- break
- }
- d := auxIntToInt32(v_0.AuxInt)
- x := v_0.Args[0]
- v.reset(Op386ROLLconst)
- v.AuxInt = int32ToAuxInt((c + d) & 31)
- v.AddArg(x)
- return true
- }
// match: (ROLLconst [0] x)
// result: x
for {
}
func rewriteValue386_Op386ROLWconst(v *Value) bool {
v_0 := v.Args[0]
- // match: (ROLWconst [c] (ROLWconst [d] x))
- // result: (ROLWconst [(c+d)&15] x)
- for {
- c := auxIntToInt16(v.AuxInt)
- if v_0.Op != Op386ROLWconst {
- break
- }
- d := auxIntToInt16(v_0.AuxInt)
- x := v_0.Args[0]
- v.reset(Op386ROLWconst)
- v.AuxInt = int16ToAuxInt((c + d) & 15)
- v.AddArg(x)
- return true
- }
// match: (ROLWconst [0] x)
// result: x
for {
v.AddArg2(x, v0)
return true
}
+ // match: (RotateLeft16 (RotateLeft16 x c) d)
+ // cond: c.Type.Size() == 8 && d.Type.Size() == 8
+ // result: (RotateLeft16 x (Add64 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft16 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 8 && d.Type.Size() == 8) {
+ break
+ }
+ v.reset(OpRotateLeft16)
+ v0 := b.NewValue0(v.Pos, OpAdd64, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft16 (RotateLeft16 x c) d)
+ // cond: c.Type.Size() == 4 && d.Type.Size() == 4
+ // result: (RotateLeft16 x (Add32 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft16 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 4 && d.Type.Size() == 4) {
+ break
+ }
+ v.reset(OpRotateLeft16)
+ v0 := b.NewValue0(v.Pos, OpAdd32, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft16 (RotateLeft16 x c) d)
+ // cond: c.Type.Size() == 2 && d.Type.Size() == 2
+ // result: (RotateLeft16 x (Add16 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft16 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 2 && d.Type.Size() == 2) {
+ break
+ }
+ v.reset(OpRotateLeft16)
+ v0 := b.NewValue0(v.Pos, OpAdd16, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft16 (RotateLeft16 x c) d)
+ // cond: c.Type.Size() == 1 && d.Type.Size() == 1
+ // result: (RotateLeft16 x (Add8 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft16 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 1 && d.Type.Size() == 1) {
+ break
+ }
+ v.reset(OpRotateLeft16)
+ v0 := b.NewValue0(v.Pos, OpAdd8, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
return false
}
func rewriteValuegeneric_OpRotateLeft32(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ // match: (RotateLeft32 (RotateLeft32 x c) d)
+ // cond: c.Type.Size() == 8 && d.Type.Size() == 8
+ // result: (RotateLeft32 x (Add64 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft32 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 8 && d.Type.Size() == 8) {
+ break
+ }
+ v.reset(OpRotateLeft32)
+ v0 := b.NewValue0(v.Pos, OpAdd64, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft32 (RotateLeft32 x c) d)
+ // cond: c.Type.Size() == 4 && d.Type.Size() == 4
+ // result: (RotateLeft32 x (Add32 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft32 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 4 && d.Type.Size() == 4) {
+ break
+ }
+ v.reset(OpRotateLeft32)
+ v0 := b.NewValue0(v.Pos, OpAdd32, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft32 (RotateLeft32 x c) d)
+ // cond: c.Type.Size() == 2 && d.Type.Size() == 2
+ // result: (RotateLeft32 x (Add16 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft32 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 2 && d.Type.Size() == 2) {
+ break
+ }
+ v.reset(OpRotateLeft32)
+ v0 := b.NewValue0(v.Pos, OpAdd16, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft32 (RotateLeft32 x c) d)
+ // cond: c.Type.Size() == 1 && d.Type.Size() == 1
+ // result: (RotateLeft32 x (Add8 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft32 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 1 && d.Type.Size() == 1) {
+ break
+ }
+ v.reset(OpRotateLeft32)
+ v0 := b.NewValue0(v.Pos, OpAdd8, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
return false
}
func rewriteValuegeneric_OpRotateLeft64(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ // match: (RotateLeft64 (RotateLeft64 x c) d)
+ // cond: c.Type.Size() == 8 && d.Type.Size() == 8
+ // result: (RotateLeft64 x (Add64 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft64 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 8 && d.Type.Size() == 8) {
+ break
+ }
+ v.reset(OpRotateLeft64)
+ v0 := b.NewValue0(v.Pos, OpAdd64, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft64 (RotateLeft64 x c) d)
+ // cond: c.Type.Size() == 4 && d.Type.Size() == 4
+ // result: (RotateLeft64 x (Add32 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft64 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 4 && d.Type.Size() == 4) {
+ break
+ }
+ v.reset(OpRotateLeft64)
+ v0 := b.NewValue0(v.Pos, OpAdd32, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft64 (RotateLeft64 x c) d)
+ // cond: c.Type.Size() == 2 && d.Type.Size() == 2
+ // result: (RotateLeft64 x (Add16 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft64 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 2 && d.Type.Size() == 2) {
+ break
+ }
+ v.reset(OpRotateLeft64)
+ v0 := b.NewValue0(v.Pos, OpAdd16, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft64 (RotateLeft64 x c) d)
+ // cond: c.Type.Size() == 1 && d.Type.Size() == 1
+ // result: (RotateLeft64 x (Add8 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft64 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 1 && d.Type.Size() == 1) {
+ break
+ }
+ v.reset(OpRotateLeft64)
+ v0 := b.NewValue0(v.Pos, OpAdd8, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
return false
}
func rewriteValuegeneric_OpRotateLeft8(v *Value) bool {
v.AddArg2(x, v0)
return true
}
+ // match: (RotateLeft8 (RotateLeft8 x c) d)
+ // cond: c.Type.Size() == 8 && d.Type.Size() == 8
+ // result: (RotateLeft8 x (Add64 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft8 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 8 && d.Type.Size() == 8) {
+ break
+ }
+ v.reset(OpRotateLeft8)
+ v0 := b.NewValue0(v.Pos, OpAdd64, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft8 (RotateLeft8 x c) d)
+ // cond: c.Type.Size() == 4 && d.Type.Size() == 4
+ // result: (RotateLeft8 x (Add32 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft8 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 4 && d.Type.Size() == 4) {
+ break
+ }
+ v.reset(OpRotateLeft8)
+ v0 := b.NewValue0(v.Pos, OpAdd32, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft8 (RotateLeft8 x c) d)
+ // cond: c.Type.Size() == 2 && d.Type.Size() == 2
+ // result: (RotateLeft8 x (Add16 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft8 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 2 && d.Type.Size() == 2) {
+ break
+ }
+ v.reset(OpRotateLeft8)
+ v0 := b.NewValue0(v.Pos, OpAdd16, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
+ // match: (RotateLeft8 (RotateLeft8 x c) d)
+ // cond: c.Type.Size() == 1 && d.Type.Size() == 1
+ // result: (RotateLeft8 x (Add8 <c.Type> c d))
+ for {
+ if v_0.Op != OpRotateLeft8 {
+ break
+ }
+ c := v_0.Args[1]
+ x := v_0.Args[0]
+ d := v_1
+ if !(c.Type.Size() == 1 && d.Type.Size() == 1) {
+ break
+ }
+ v.reset(OpRotateLeft8)
+ v0 := b.NewValue0(v.Pos, OpAdd8, c.Type)
+ v0.AddArg2(c, d)
+ v.AddArg2(x, v0)
+ return true
+ }
return false
}
func rewriteValuegeneric_OpRound32F(v *Value) bool {
return rot32nc(x, 7)
}
+func doubleRotate(x uint64) uint64 {
+ x = (x << 5) | (x >> 59)
+ // amd64:"ROLQ\t[$]15"
+ // arm64:"ROR\t[$]49"
+ x = (x << 10) | (x >> 54)
+ return x
+}
+
// --------------------------------------- //
// Combined Rotate + Masking operations //
// --------------------------------------- //
i++
// ppc64le: "RLWNM\tR[0-9]+, R[0-9]+, [$]16, [$]23, R[0-9]+"
// ppc64: "RLWNM\tR[0-9]+, R[0-9]+, [$]16, [$]23, R[0-9]+"
- a[i] = bits.RotateLeft32(a[3], r) & 0xFF00
+ a[i] = bits.RotateLeft32(a[i], r) & 0xFF00
i++
// ppc64le: "RLWNM\tR[0-9]+, R[0-9]+, [$]20, [$]11, R[0-9]+"
// ppc64: "RLWNM\tR[0-9]+, R[0-9]+, [$]20, [$]11, R[0-9]+"
- a[i] = bits.RotateLeft32(a[3], r) & 0xFFF00FFF
+ a[i] = bits.RotateLeft32(a[i], r) & 0xFFF00FFF
i++
// ppc64le: "RLWNM\t[$]4, R[0-9]+, [$]20, [$]11, R[0-9]+"
// ppc64: "RLWNM\t[$]4, R[0-9]+, [$]20, [$]11, R[0-9]+"
- a[i] = bits.RotateLeft32(a[3], 4) & 0xFFF00FFF
+ a[i] = bits.RotateLeft32(a[i], 4) & 0xFFF00FFF
i++
}