-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NVPTX] Implement isTruncateFree(EVT FromVT, EVT ToVT)
#138605
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -155,11 +155,19 @@ class NVPTXTargetLowering : public TargetLowering { | |||
| Instruction *I = nullptr) const override; | ||||
|
|
||||
| bool isTruncateFree(Type *SrcTy, Type *DstTy) const override { | ||||
| // Truncating 64-bit to 32-bit is free in SASS. | ||||
| if (!SrcTy->isIntegerTy() || !DstTy->isIntegerTy()) | ||||
| if (!(SrcTy->isIntegerTy() && DstTy->isIntegerTy())) | ||||
| return false; | ||||
| return SrcTy->getPrimitiveSizeInBits() == 64 && | ||||
| DstTy->getPrimitiveSizeInBits() == 32; | ||||
| if (SrcTy->getPrimitiveSizeInBits() <= DstTy->getPrimitiveSizeInBits()) | ||||
| return false; | ||||
|
Comment on lines
-159
to
+161
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be valid to call
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe so. The second condition is explicitly mentioned in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. What about the check for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's a good point. When expressed in PTX, the vectors become registers and thus do not guarantee contiguousness. |
||||
| return DstTy->getPrimitiveSizeInBits() % 32 == 0; | ||||
| } | ||||
|
|
||||
| bool isTruncateFree(EVT FromVT, EVT ToVT) const override { | ||||
| if (!(FromVT.isScalarInteger() && ToVT.isScalarInteger())) | ||||
| return false; | ||||
| if (FromVT.getSizeInBits() <= ToVT.getSizeInBits()) | ||||
| return false; | ||||
|
Comment on lines
+166
to
+169
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as above. |
||||
| return ToVT.getSizeInBits() % 32 == 0; | ||||
| } | ||||
|
|
||||
| EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Ctx, | ||||
|
|
||||
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 Hexagon is the only target that does it this way, but seems simpler:
llvm-project/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
Line 2145 in 1c1238d