Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

cfallin
Copy link
Member

@cfallin cfallin commented Oct 17, 2022

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 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 bytecodealliance#5047.
@cfallin cfallin requested review from elliottt and fitzgen October 17, 2022 06:07
@cfallin
Copy link
Member Author

cfallin commented Oct 17, 2022

cc @afonso360

@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Oct 17, 2022
@bjorn3
Copy link
Contributor

bjorn3 commented Oct 17, 2022

Arguably an iconst.i32 should not have nonzero bits in the upper 32 of its immediate

Iconst uses the signed Imm64 type, so it is not weird to see a sign extended iconst.

Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cfallin cfallin merged commit 1aaea27 into bytecodealliance:main Oct 17, 2022
@cfallin cfallin deleted the fix-iconst-egraph branch October 17, 2022 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cranelift: uextend + iconst fails with egraphs
3 participants