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.
23 lines
416 B
Plaintext
23 lines
416 B
Plaintext
test optimize
|
|
set opt_level=none
|
|
set use_egraphs=true
|
|
target x86_64
|
|
|
|
function %f0(i32) -> i32 {
|
|
block0(v0: i32):
|
|
v1 = iconst.i32 2
|
|
v2 = imul v0, v1
|
|
; check: v1 = iadd v0, v0
|
|
; 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
|
|
}
|