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

don't store UntypedInt with 4-bit APInt values #125

Merged
merged 1 commit into from
Nov 28, 2014

Conversation

chenyang78
Copy link
Contributor

Integer 8 is represent as b1000 in a 4-bit APInt manner.
Later, when we translate this APInt value into a const using
APInt.sextOrTrunc, we get b11111000 back, which is not what
we want. The bad intepretation only occurs when
we infer the type of an integer, i.e., an integer without :iN.
Note that b11111000 is unsigned char 248, which is why we see
instruction "%8:i1 = eq 248:i8, %0" in John's example.

The fix is to use multiple of 5. It should always be safe.
Also, we won't increase too much memory usage because
it's only for parsing replacements, which are small.

@chenyang78 chenyang78 mentioned this pull request Nov 28, 2014
@buildhive
Copy link

Google » souper #338 SUCCESS
This pull request looks good
(what's this?)

@regehr
Copy link
Collaborator

regehr commented Nov 28, 2014

Yang, thanks! I don't see a problem with 8 bits but if I understand correctly, 5 would be enough?

@regehr
Copy link
Collaborator

regehr commented Nov 28, 2014

Yang can you redo for 5 bits and squash? Thanks!

@chenyang78
Copy link
Contributor Author

5 bits should be enough. Updated. Thanks.

@chenyang78
Copy link
Contributor Author

Wait a second. I will need to update the commit message. Sorry about that!

@buildhive
Copy link

Google » souper #341 SUCCESS
This pull request looks good
(what's this?)

Integer 8 is represent as b1000 in a 4-bit APInt manner.
Later, when we translate this APInt value into a const using
APInt.sextOrTrunc, we get b11111000 back, which is not what
we want. The bad intepretation only occurs when
we infer the type of an integer, i.e., an integer without :iN.
Note that b11111000 is unsigned char 248, which is why we see
instruction "%8:i1 = eq 248:i8, %0" in John's example.

The fix is to use multiple of 5. It should always be safe.
Also, we won't increase too much memory usage because
it's only for parsing replacements, which are small.
@chenyang78
Copy link
Contributor Author

John, pull request has been updated. Thanks!

@buildhive
Copy link

Google » souper #342 SUCCESS
This pull request looks good
(what's this?)

regehr added a commit that referenced this pull request Nov 28, 2014
don't store UntypedInt with 4-bit APInt values
@regehr regehr merged commit e6e01de into google:master Nov 28, 2014
@regehr
Copy link
Collaborator

regehr commented Nov 28, 2014

Thanks Yang!

@buildhive
Copy link

Google » souper #343 SUCCESS
This pull request looks good
(what's this?)

std::string Test;
std::string ExpectedReplacement;
} Tests[] = {
{ R"i(%0:i8 = var ; 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a RoundTrip test?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes I'll do that now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I missed something, we can't simply include the test into RoundTrip category. The input is "%4:i1= eq 8, %0 ", and the output is "%4 = eq 8:i8, %0". The bug occured when we inferred the width of "8", so we can't add :i8 to it. On the other hand, i8 was printed out by our Inst printer. This is way I explicitly added one more test here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Never mind. I see that RoundTrip test has similar functionality for checking equivalence. I overlooked it.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could add it to NonEqualTests, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I saw that. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Go ahead if you want to, Yang, I was going to do this earlier but something came up.

@chenyang78 chenyang78 deleted the parser branch November 29, 2014 01:50
@chenyang78
Copy link
Contributor Author

OK, I am on it . Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants