-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AMDGPU][GlobalIsel] Introduce isRegType to check for legal types, instead of checking bit width. #68189
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
✅ With the latest revision this PR passed the C/C++ code formatter. |
a7077d7
to
0f19020
Compare
typeInSet(Ty, AllPtrTypes) || Ty.isPointer(); | ||
} | ||
|
||
static LegalityPredicate isRegType(unsigned TypeIdx, |
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.
Needs a comment explaining what this is. In particular how is it different from isRegisterType and why do we need both (and can we have better names for them)?
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.
isRegisterType check is not sufficient. For example it considers v13s32 as legal which doesn't have corresponding reg class. If this approach is accepted, this would be the first step to replace isRegisterType with isRegType (we can name it differently, of course). The idea is to replace it step by step because it is not as straight forward as replacing all calls to isRegisterType with isRegType.
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.
That sounds like a good plan. Could you add a TODO comment to isRegisterType saying that all uses should be migrated to isRegType?
There is also some relevant discussion on https://reviews.llvm.org/D148096 which introduced isIllegalRegisterType. Do we really need both isIllegalRegisterType and isRegType? |
I think once we replace all usage of isRegisterType we could do without isIllegalRegisterType. |
const LLT V2GlobalPtr = LLT::fixed_vector(2, GlobalPtr); | ||
const LLT V4GlobalPtr = LLT::fixed_vector(4, GlobalPtr); | ||
|
||
std::initializer_list<LLT> AllPtrTypes{V2FlatPtr, V3LocalPtr, V5LocalPtr, |
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.
@jayfoad What should we do with vectors of pointers, list all possible vector sizes that fit in some register class?
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 guess so. Can you write test cases for legalizing bitcast, that fail because you don't handle all pointer vector types here yet?
@jayfoad ping |
0fd67a8
to
f174145
Compare
@jayfoad ping |
Could you add a TODO comment to isIllegalRegisterType please? |
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've just taken a fresh look at this. I do have a couple of concerns:
- It introduces yet another list of supported register classes, which will need to be updated whenever we add a new one. But maybe that is unavoidable.
- It looks like
isRegisterClassType
will not be super fast, especially since it has to construct all the pointer types on every call.
const LLT V2GlobalPtr = LLT::fixed_vector(2, GlobalPtr); | ||
const LLT V4GlobalPtr = LLT::fixed_vector(4, GlobalPtr); | ||
|
||
std::initializer_list<LLT> AllPtrTypes{V2FlatPtr, V3LocalPtr, V5LocalPtr, |
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 guess so. Can you write test cases for legalizing bitcast, that fail because you don't handle all pointer vector types here yet?
|
44016ee
to
f2c4211
Compare
|
||
// Checks whether a type is in the list of legal register types. | ||
static bool isRegisterClassType(LLT Ty) { | ||
if (Ty.isVector() && Ty.getElementType().isPointer()) |
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.
After #81283 this could be isPointerOrPointerVector.
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.
Which one should go in first?
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.
Doesn't matter.
78c7f36
to
fae364a
Compare
|
||
// Checks whether a type is in the list of legal register types. | ||
static bool isRegisterClassType(LLT Ty) { | ||
if (Ty.isVector() && Ty.getElementType().isPointer()) |
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.
Doesn't matter.
… types, instead of checking bit width.
fae364a
to
780b970
Compare
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 reasonable to me, thanks.
In D151116 it was suggested to have a set of classes to cover every possible case. This does it for bitcast first.
closes #79578