mirror of
https://github.com/golang/go
synced 2024-11-24 03:40:16 -07:00
cmd/compile: coalesce a few shift rules for wasm
Change-Id: I1b76daba90afd474390db8d9c238445abaac7ca6 Reviewed-on: https://go-review.googlesource.com/c/go/+/182557 Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Richard Musiol <neelance@gmail.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
3d48ae355b
commit
b9ef4c0f56
@ -103,67 +103,43 @@
|
||||
// Unsigned shifts need to return 0 if shift amount is >= width of shifted value.
|
||||
|
||||
(Lsh64x64 x y) -> (Select (I64Shl x y) (I64Const [0]) (I64LtU y (I64Const [64])))
|
||||
(Lsh64x32 x y) -> (Lsh64x64 x (ZeroExt32to64 y))
|
||||
(Lsh64x16 x y) -> (Lsh64x64 x (ZeroExt16to64 y))
|
||||
(Lsh64x8 x y) -> (Lsh64x64 x (ZeroExt8to64 y))
|
||||
(Lsh64x(32|16|8) x y) -> (Lsh64x64 x (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Lsh32x64 x y) -> (Lsh64x64 x y)
|
||||
(Lsh32x32 x y) -> (Lsh64x64 x (ZeroExt32to64 y))
|
||||
(Lsh32x16 x y) -> (Lsh64x64 x (ZeroExt16to64 y))
|
||||
(Lsh32x8 x y) -> (Lsh64x64 x (ZeroExt8to64 y))
|
||||
(Lsh32x(32|16|8) x y) -> (Lsh64x64 x (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Lsh16x64 x y) -> (Lsh64x64 x y)
|
||||
(Lsh16x32 x y) -> (Lsh64x64 x (ZeroExt32to64 y))
|
||||
(Lsh16x16 x y) -> (Lsh64x64 x (ZeroExt16to64 y))
|
||||
(Lsh16x8 x y) -> (Lsh64x64 x (ZeroExt8to64 y))
|
||||
(Lsh16x(32|16|8) x y) -> (Lsh64x64 x (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Lsh8x64 x y) -> (Lsh64x64 x y)
|
||||
(Lsh8x32 x y) -> (Lsh64x64 x (ZeroExt32to64 y))
|
||||
(Lsh8x16 x y) -> (Lsh64x64 x (ZeroExt16to64 y))
|
||||
(Lsh8x8 x y) -> (Lsh64x64 x (ZeroExt8to64 y))
|
||||
(Lsh8x(32|16|8) x y) -> (Lsh64x64 x (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh64Ux64 x y) -> (Select (I64ShrU x y) (I64Const [0]) (I64LtU y (I64Const [64])))
|
||||
(Rsh64Ux32 x y) -> (Rsh64Ux64 x (ZeroExt32to64 y))
|
||||
(Rsh64Ux16 x y) -> (Rsh64Ux64 x (ZeroExt16to64 y))
|
||||
(Rsh64Ux8 x y) -> (Rsh64Ux64 x (ZeroExt8to64 y))
|
||||
(Rsh64Ux(32|16|8) x y) -> (Rsh64Ux64 x (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh32Ux64 x y) -> (Rsh64Ux64 (ZeroExt32to64 x) y)
|
||||
(Rsh32Ux32 x y) -> (Rsh64Ux64 (ZeroExt32to64 x) (ZeroExt32to64 y))
|
||||
(Rsh32Ux16 x y) -> (Rsh64Ux64 (ZeroExt32to64 x) (ZeroExt16to64 y))
|
||||
(Rsh32Ux8 x y) -> (Rsh64Ux64 (ZeroExt32to64 x) (ZeroExt8to64 y))
|
||||
(Rsh32Ux(32|16|8) x y) -> (Rsh64Ux64 (ZeroExt32to64 x) (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh16Ux64 x y) -> (Rsh64Ux64 (ZeroExt16to64 x) y)
|
||||
(Rsh16Ux32 x y) -> (Rsh64Ux64 (ZeroExt16to64 x) (ZeroExt32to64 y))
|
||||
(Rsh16Ux16 x y) -> (Rsh64Ux64 (ZeroExt16to64 x) (ZeroExt16to64 y))
|
||||
(Rsh16Ux8 x y) -> (Rsh64Ux64 (ZeroExt16to64 x) (ZeroExt8to64 y))
|
||||
(Rsh16Ux(32|16|8) x y) -> (Rsh64Ux64 (ZeroExt16to64 x) (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh8Ux64 x y) -> (Rsh64Ux64 (ZeroExt8to64 x) y)
|
||||
(Rsh8Ux32 x y) -> (Rsh64Ux64 (ZeroExt8to64 x) (ZeroExt32to64 y))
|
||||
(Rsh8Ux16 x y) -> (Rsh64Ux64 (ZeroExt8to64 x) (ZeroExt16to64 y))
|
||||
(Rsh8Ux8 x y) -> (Rsh64Ux64 (ZeroExt8to64 x) (ZeroExt8to64 y))
|
||||
(Rsh8Ux(32|16|8) x y) -> (Rsh64Ux64 (ZeroExt8to64 x) (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
// Signed right shift needs to return 0/-1 if shift amount is >= width of shifted value.
|
||||
// We implement this by setting the shift value to (width - 1) if the shift value is >= width.
|
||||
|
||||
(Rsh64x64 x y) -> (I64ShrS x (Select <typ.Int64> y (I64Const [63]) (I64LtU y (I64Const [64]))))
|
||||
(Rsh64x32 x y) -> (Rsh64x64 x (ZeroExt32to64 y))
|
||||
(Rsh64x16 x y) -> (Rsh64x64 x (ZeroExt16to64 y))
|
||||
(Rsh64x8 x y) -> (Rsh64x64 x (ZeroExt8to64 y))
|
||||
(Rsh64x(32|16|8) x y) -> (Rsh64x64 x (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh32x64 x y) -> (Rsh64x64 (SignExt32to64 x) y)
|
||||
(Rsh32x32 x y) -> (Rsh64x64 (SignExt32to64 x) (ZeroExt32to64 y))
|
||||
(Rsh32x16 x y) -> (Rsh64x64 (SignExt32to64 x) (ZeroExt16to64 y))
|
||||
(Rsh32x8 x y) -> (Rsh64x64 (SignExt32to64 x) (ZeroExt8to64 y))
|
||||
(Rsh32x(32|16|8) x y) -> (Rsh64x64 (SignExt32to64 x) (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh16x64 x y) -> (Rsh64x64 (SignExt16to64 x) y)
|
||||
(Rsh16x32 x y) -> (Rsh64x64 (SignExt16to64 x) (ZeroExt32to64 y))
|
||||
(Rsh16x16 x y) -> (Rsh64x64 (SignExt16to64 x) (ZeroExt16to64 y))
|
||||
(Rsh16x8 x y) -> (Rsh64x64 (SignExt16to64 x) (ZeroExt8to64 y))
|
||||
(Rsh16x(32|16|8) x y) -> (Rsh64x64 (SignExt16to64 x) (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
(Rsh8x64 x y) -> (Rsh64x64 (SignExt8to64 x) y)
|
||||
(Rsh8x32 x y) -> (Rsh64x64 (SignExt8to64 x) (ZeroExt32to64 y))
|
||||
(Rsh8x16 x y) -> (Rsh64x64 (SignExt8to64 x) (ZeroExt16to64 y))
|
||||
(Rsh8x8 x y) -> (Rsh64x64 (SignExt8to64 x) (ZeroExt8to64 y))
|
||||
(Rsh8x(32|16|8) x y) -> (Rsh64x64 (SignExt8to64 x) (ZeroExt(32|16|8)to64 y))
|
||||
|
||||
// Lowering rotates
|
||||
(RotateLeft8 <t> x (I64Const [c])) -> (Or8 (Lsh8x64 <t> x (I64Const [c&7])) (Rsh8Ux64 <t> x (I64Const [-c&7])))
|
||||
|
Loading…
Reference in New Issue
Block a user