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

@@ -3,7 +3,7 @@ set opt_level=none
set use_egraphs=true
target x86_64
function %f(i32) -> i32 {
function %f0(i32) -> i32 {
block0(v0: i32):
v1 = iconst.i32 2
v2 = imul v0, v1
@@ -11,3 +11,12 @@ block0(v0: i32):
; nextln: return v1
return v2
}
function %f1() -> i64 {
block0:
v0 = iconst.i32 0xffff_ffff_9876_5432
v1 = uextend.i64 v0
return v1
; check: v0 = iconst.i64 0x9876_5432
; nextln: return v0 ; v0 = 0x9876_5432
}