egraph opts: fix uextend-of-i32. (#5061)

This is a simple error in the const-prop rules: uextend was not
masking iconst's u64 immediate when extending from i32 to
i64. Arguably an iconst.i32 should not have nonzero bits in the upper
32 of its immediate, but that's a separate design question. For now,
if our invariant is that the upper bits are ignored, then it is
required to mask the bits when const-evaling a `uextend`.

Fixes #5047.
This commit is contained in:
Chris Fallin
2022-10-17 12:45:49 -07:00
committed by GitHub
parent ff0c45b4a0
commit 1aaea279e5
4 changed files with 20 additions and 3 deletions

View File

@@ -7,8 +7,8 @@
;; can freely rewrite e.g. `x+y-y` to `x`.
;; uextend/sextend of a constant.
(rule (simplify (uextend $I64 (iconst $I32 imm)))
(iconst $I64 imm))
(rule (simplify (uextend $I64 (iconst $I32 (u64_from_imm64 imm))))
(iconst $I64 (imm64 (u64_uextend_u32 imm))))
(rule (simplify (sextend $I64 (iconst $I32 (u64_from_imm64 imm))))
(iconst $I64 (imm64 (u64_sextend_u32 imm))))