-
Notifications
You must be signed in to change notification settings - Fork 203
Bitcasting at control flow exits #1272
Bitcasting at control flow exits #1272
Conversation
state.peekn(return_count), | ||
&builder.func.signature.returns.clone(), // TODO this use of signature | ||
// returns may be incorrect; what if this End is in a different control flow | ||
// structure? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is still a WIP because 1) I'm not yet confident that I've covered all of the possible cases where a vector should be bitcast to another type and 2) in situations like the above (Operator::End
), I am pretending that I can bitcast to the function return types but in fact the End
may be the end of some other block, not necessarily the end of a function (though adding this makes more SIMD spec tests pass).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be on the right track, except that you should use the block's signature, rather than the function's signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach in the code so far is that operations bitcast their inputs as needed, which I think makes sense.
To do this for the function exits, we should do it at the point of the return_
calls, both the one for the Return
opcode as you have here, but also the one in func_translator.rs, which is the return that gets inserted at the end of a function to handle the case where no Return
opcode was present at end.
That leaves the question of control-flow merge points.
state.peekn(return_count), | ||
&builder.func.signature.returns.clone(), // TODO this use of signature | ||
// returns may be incorrect; what if this End is in a different control flow | ||
// structure? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be on the right track, except that you should use the block's signature, rather than the function's signature.
e439684
to
0924c8f
Compare
@sunfishcode, I pushed some commits that should resolve your comments above. I am still thinking through your comment about control flow merge points: shouldn't control flow divergences merge back into a common EBB? If that is the case, I think my 114ca62 commit might solve that problem--I look at the parameters of the EBB we jump to at an But perhaps you meant something else: I believe we will have to bitcast in some way in all the cases listed as control instructions in the spec; e.g., before a |
cdf17d3
to
0cd40e0
Compare
963ceb6
to
4707e13
Compare
@sunfishcode, I think this is ready for another look. I am open to adding any new test cases you can think of (perhaps |
(Unflagging me for review, since @sunfishcode is already flagged in and did review a first time.) |
4707e13
to
03b0fcb
Compare
Also, retrieves the correct EBB header types for bitcasting on Operator::End.
This eliminates some duplicate code and avoids extra `use`s of `Vec`.
…both this and Signature::return_types
This matches the organization of the other Signature::num_*_params methods.
03b0fcb
to
9657262
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for seeing this through!
iadd
needs to operate oni32x4
and not the defaulti8x16
. This PR adds moreraw_bitcasts
so that function signatures returning vectors will have some bitcasts beforereturn
to convert the actual vector type (e.g.i32x4
) into the expected signature type (e.g. the defaulti8x16
). I propose we merge something like this first so I can get more SIMD spec tests running and circle back to a better solution to #1192 afterwards.