-
Notifications
You must be signed in to change notification settings - Fork 11.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
[MLIR] Update APInt construction to correctly set isSigned/implicitTrunc #110466
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
It seems strange we hit an issue here since we're passing the expected
isSigned
here, that would be a bug right?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.
Or maybe I am missing how the assertion operates and when is implicitTrunc legit to use?
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.
Yes, places marked with TODO probably shouldn't be using implicitTrunc. Here are the failures if we drop it: https://gist.github.com/nikic/d69e30cf1d28ef5988363dc11e203159
I'm guessing the main problem is
llvm-project/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
Line 120 in 0e8555d
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.
What is the right way to avoid an implicit truncation with signless integers?
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.
Not familiar with MLIR, but probably by using a ctor that accepts APInt? That way you can explicitly specify that the constant needs to be sign extended.
Or possibly the code here should be setting signed=true for signless integers, as parameter is int64_t so signed value should be the default assumption?
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 "proper" solution here is probably to either a) Only allow constructing signless integers from APInt or b) only allow constructing them from plain integers for bit widths <= 64 bit, as the sign distinction only becomes really problematic for larger bit widths.
But in any case, this is not something I want to touch in this PR...
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.
Seems like you merged without further approvals or resolving completely this thread here?
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.
Sorry, I took this as a discussion on how the TODO could be resolved in the future, not a blocking concern for this PR. Was there something you wanted me to change in this PR?
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 isn't super clear or inciting to a fix. The TODO is a question? Such TODO looks to me like a PR "not ready to merge" because the actual "TODO" needs to be figured.
I would have tried encoded more of the discussion in the TODO actually, to make it more accessible for anyone seeing this TODO in terms of investigating what to do to fix it and not have to rediscover the investigation you done here.
I would think that a better TODO would look something like:
I'm actually not even sure how to finish the sentence, you didn't expand enough on the problem you saw with signless integer ("Tried that, and it causes other failures.").
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 see. I agree that the TODO is not super clear without some context. What I'd like to do is to add a reference to #112510 (which I just filed) to these TODOs, so there is a place that provides a more detailed explanation of the purpose of the TODO and how it may be resolved.
I don't want to add detailed analysis to individual TODO comments, as the point of leaving them is so that I don't have to analyze each one in detail. (For the record, I'm trying to get this assertion enabled for more than half a year already, and not tracking down everything to its leafs is part of the compromise to make this feasible at all.)