Add egraph cprop optimizations for splat (#6148)
This commit adds constant-propagation optimizations for `splat`-of-constant to produce a `vconst` node. This should help later hoisting these constants out of loops if it shows up in wasm.
This commit is contained in:
@@ -171,3 +171,27 @@
|
||||
y)
|
||||
|
||||
;; TODO: fadd, fsub, fmul, fdiv, fneg, fabs
|
||||
|
||||
;; A splat of a constant can become a direct `vconst` with the appropriate bit
|
||||
;; pattern.
|
||||
(rule (simplify (splat dst (iconst $I8 n)))
|
||||
(vconst dst (splat8 (u64_uextend_imm64 $I8 n))))
|
||||
(rule (simplify (splat dst (iconst $I16 n)))
|
||||
(vconst dst (splat16 (u64_uextend_imm64 $I16 n))))
|
||||
(rule (simplify (splat dst (iconst $I32 n)))
|
||||
(vconst dst (splat32 (u64_uextend_imm64 $I32 n))))
|
||||
(rule (simplify (splat dst (iconst $I64 n)))
|
||||
(vconst dst (splat64 (u64_uextend_imm64 $I64 n))))
|
||||
(rule (simplify (splat dst (f32const _ (u32_from_ieee32 n))))
|
||||
(vconst dst (splat32 n)))
|
||||
(rule (simplify (splat dst (f64const _ (u64_from_ieee64 n))))
|
||||
(vconst dst (splat64 n)))
|
||||
|
||||
(decl splat8 (u64) Constant)
|
||||
(rule (splat8 n) (splat16 (u64_or n (u64_shl n 8))))
|
||||
(decl splat16 (u64) Constant)
|
||||
(rule (splat16 n) (splat32 (u64_or n (u64_shl n 16))))
|
||||
(decl splat32 (u64) Constant)
|
||||
(rule (splat32 n) (splat64 (u64_or n (u64_shl n 32))))
|
||||
(decl splat64 (u64) Constant)
|
||||
(extern constructor splat64 splat64)
|
||||
|
||||
Reference in New Issue
Block a user