-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Reduce the size of the index used for RVV intrinsics. NFC #74906
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
Conversation
@llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-clang Author: Craig Topper (topperc) ChangesRather than using size_t, use unsigned. We don't have more than 4 billion intrinsics. Full diff: https://github.com/llvm/llvm-project/pull/74906.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index 9a5aecf669a07..b7add334c7f37 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -49,7 +49,7 @@ struct RVVIntrinsicDef {
struct RVVOverloadIntrinsicDef {
// Indexes of RISCVIntrinsicManagerImpl::IntrinsicList.
- SmallVector<size_t, 8> Indexes;
+ SmallVector<unsigned, 8> Indexes;
};
} // namespace
@@ -168,7 +168,7 @@ class RISCVIntrinsicManagerImpl : public sema::RISCVIntrinsicManager {
// List of all RVV intrinsic.
std::vector<RVVIntrinsicDef> IntrinsicList;
// Mapping function name to index of IntrinsicList.
- StringMap<size_t> Intrinsics;
+ StringMap<unsigned> Intrinsics;
// Mapping function name to RVVOverloadIntrinsicDef.
StringMap<RVVOverloadIntrinsicDef> OverloadIntrinsics;
@@ -392,7 +392,7 @@ void RISCVIntrinsicManagerImpl::InitRVVIntrinsic(
Record.HasFRMRoundModeOp);
// Put into IntrinsicList.
- size_t Index = IntrinsicList.size();
+ unsigned Index = IntrinsicList.size();
IntrinsicList.push_back({Name, OverloadedName, BuiltinName, Signature});
// Creating mapping to Intrinsics.
|
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 - though maybe use uint32_t?
Looking at this code, the whole Intrinsics map vs OverloadIntrinsic map structure loops to have heavy redundancy and could be greatly simplified. Maybe a follow up?
Rather than using size_t, use unsigned. We don't have more than 4 billion intrinsics.
0067a9c
to
86ffbd6
Compare
Did you have a specific idea in mind? Maybe we could use a single map and use the size of the vector being more than 1 to detect overloaded? I'm skeptical that the |
That's basically where I was going. We track every name to index mapping twice, and we really only need to do so once. Maybe the cost of a SmallVector<uint32_t, 1> is high enough to be worth two structures, but then why not have a signal value in the primary map and a much smaller index keyed overload structure? |
Rather than using size_t, use unsigned. We don't have more than 4 billion intrinsics.