-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix BOX import to not create "wrong" casts #57094
Conversation
All casts in the IR have TYP_INT, except for this one case. Fix it by using genActualType. Also add a comment explaining the reason a cast is needed at all in case the types are small.
f5ea7c5
to
e1eee69
Compare
assert((varTypeIsFloating(srcTyp) && varTypeIsFloating(dstTyp)) || | ||
(varTypeIsIntegral(srcTyp) && varTypeIsIntegral(dstTyp))); |
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 assert was redundant with the one above the if
.
It would be good to have a test with this change |
What kind do you have in mind? This change is not fixing a bug per se, just an inconsistency internal to the IR. |
I was thinking having tests that make sure enum ShortEnum : short
{
None,
Boo
}
static bool Test(ShortEnum s) => s.HasFlag(ShortEnum.Boo); |
I see. We already have a test for the optimization here, though it deals more with the intricacies of how many flavors of boxes can one see. I will see about adding some more coverage of small type mixes, though I do not expect us to have issues in this area specifically (there are definitely issues with dealing with these implicit truncations in general...). |
@JulieLeeMSFT you can cross this one off the list I gave you the other day. |
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.
LGTM.
All casts in the IR have TYP_INT, except for this one case. Fix it by using
genActualType
.Also add a comment explaining the reason a cast is needed at all in case the types are small.
No diffs as per SPMI. Note: it looks like the
Enum.HasFlag
optimization has been fixed to use actual types.Fixes #10843