fix(cranelift): correct sign extension operators to use ireduce result#12609
Open
radik878 wants to merge 1 commit intobytecodealliance:mainfrom
Open
fix(cranelift): correct sign extension operators to use ireduce result#12609radik878 wants to merge 1 commit intobytecodealliance:mainfrom
radik878 wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
Member
|
@radik878 I don't think your description is correct. The existing code pops, reduces, pushes; then pops, sign-extends, and pushes. The intermediate push-then-pop has the effect of carrying through the result of the reduce to the sign-extend. Nothing is discarded, and the "next value on the stack" is not used. I didn't write this code so I don't know the intent for sure but I can imagine this is meant to express the operator as a composition of the two operations. It's a little odd, but it's not incorrect. Your description ("fix") implies that you observed an incorrect execution. Did you, and if so can you show the test case here? And can you explain your reasoning a bit more? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong: The sign extension operators (
i32.extend8_s,i32.extend16_s,i64.extend8_s,i64.extend16_s,i64.extend32_s) were incorrectly discarding theireduceresult. The code was pushing theireduceresult to the value stack and then immediately popping a different value (the next value on the stack) for thesextendoperation.Changes: Store the
ireduceresult in a local variable and use it directly insextendinstead of popping from the stack.