[TableGen] Simplify MachineValueTypeSet::iterator::find_from_pos. NFC#169227
Merged
[TableGen] Simplify MachineValueTypeSet::iterator::find_from_pos. NFC#169227
Conversation
Merge the SkipBits!=0 handling into the first iteration of the word loop. This is the same code structure used by BitVector::find_first_in.
Member
|
@llvm/pr-subscribers-tablegen Author: Craig Topper (topperc) ChangesMerge the SkipBits!=0 handling into the first iteration of the word loop. This is the same code structure used by BitVector::find_first_in. Full diff: https://github.com/llvm/llvm-project/pull/169227.diff 1 Files Affected:
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
index 8146f54cd3db5..633327e2f74e5 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
@@ -138,25 +138,19 @@ struct MachineValueTypeSet {
private:
unsigned find_from_pos(unsigned P) const {
unsigned SkipWords = P / WordWidth;
- unsigned SkipBits = P % WordWidth;
- unsigned Count = SkipWords * WordWidth;
-
- // If P is in the middle of a word, process it manually here, because
- // the trailing bits need to be masked off to use findFirstSet.
- if (SkipBits != 0) {
- WordType W = Set->Words[SkipWords];
- W &= maskLeadingOnes<WordType>(WordWidth - SkipBits);
- if (W != 0)
- return Count + llvm::countr_zero(W);
- Count += WordWidth;
- SkipWords++;
- }
for (unsigned i = SkipWords; i != NumWords; ++i) {
WordType W = Set->Words[i];
+
+ // If P is in the middle of a word, process it manually here, because
+ // the trailing bits need to be masked off to use countr_zero.
+ if (i == SkipWords) {
+ unsigned SkipBits = P % WordWidth;
+ W &= maskTrailingZeros<WordType>(SkipBits);
+ }
+
if (W != 0)
- return Count + llvm::countr_zero(W);
- Count += WordWidth;
+ return i * WordWidth + llvm::countr_zero(W);
}
return Capacity;
}
|
aadeshps-mcw
pushed a commit
to aadeshps-mcw/llvm-project
that referenced
this pull request
Nov 26, 2025
…llvm#169227) Merge the SkipBits!=0 handling into the first iteration of the word loop. This is the same code structure used by BitVector::find_first_in.
Priyanshu3820
pushed a commit
to Priyanshu3820/llvm-project
that referenced
this pull request
Nov 26, 2025
…llvm#169227) Merge the SkipBits!=0 handling into the first iteration of the word loop. This is the same code structure used by BitVector::find_first_in.
augusto2112
pushed a commit
to augusto2112/llvm-project
that referenced
this pull request
Dec 3, 2025
…llvm#169227) Merge the SkipBits!=0 handling into the first iteration of the word loop. This is the same code structure used by BitVector::find_first_in.
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.
Merge the SkipBits!=0 handling into the first iteration of the word loop. This is the same code structure used by BitVector::find_first_in.