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

Replace simm32 extractor with i32_from_iconst #8842

Merged

Conversation

alexcrichton
Copy link
Member

This commit removes the simm32 extractor from lowerings as it's not as useful as it was when it was first introduced. Nowadays an Imm64 needs to be interpreted with the type known as well to understand whether bits being masked off is significant or not. The old simm32 extractor only took Imm64 meaning that it was unable to do this and wouldn't match negative numbers. This is because the high 32 bits of Imm64 were always zero and simm64 would take the i64 value from Imm64 and try to convert it to an i32.

This commit replaces simm32, and uses of it, with a new extractor i32_from_iconst. This matches the preexisting i64_from_iconst and is able to take the type of the value into account and produce a correctly sign-extended value.

cc #8706

This commit removes the `simm32` extractor from lowerings as it's not as
useful as it was when it was first introduced. Nowadays an `Imm64` needs
to be interpreted with the type known as well to understand whether bits
being masked off is significant or not. The old `simm32` extractor only
took `Imm64` meaning that it was unable to do this and wouldn't match
negative numbers. This is because the high 32 bits of `Imm64` were
always zero and `simm64` would take the `i64` value from `Imm64` and try
to convert it to an `i32`.

This commit replaces `simm32`, and uses of it, with a new extractor
`i32_from_iconst`. This matches the preexisting `i64_from_iconst` and is
able to take the type of the value into account and produce a correctly
sign-extended value.

cc bytecodealliance#8706
@alexcrichton alexcrichton requested review from a team as code owners June 19, 2024 18:34
@alexcrichton alexcrichton requested review from abrown and pchickey and removed request for a team June 19, 2024 18:34
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen labels Jun 19, 2024
@alexcrichton alexcrichton added this pull request to the merge queue Jun 20, 2024
Merged via the queue into bytecodealliance:main with commit d4c5bcc Jun 20, 2024
60 checks passed
@alexcrichton alexcrichton deleted the better-simm32-matching branch June 20, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants