-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NVPTX] Implement isTruncateFree and isZExtFree for i32/i64 Optimizations #114601
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
…romVT, EVT ToVT) in NVPTX.
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-backend-nvptx Author: None (Quark-69) ChangesImplemented isTruncateFree and isZExtFree virtual functions in NVPTXTargetLowering to optimize i32/i64 truncation and zero-extension operations. Full diff: https://github.com/llvm/llvm-project/pull/114601.diff 2 Files Affected:
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
index 379a4a77647079..2f2f204d0d36f8 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -3285,6 +3285,14 @@ bool NVPTXTargetLowering::splitValueIntoRegisterParts(
return false;
}
+bool llvm::NVPTXTargetLowering::isTruncateFree(EVT FromVT, EVT ToVT) const {
+ return (FromVT.getSimpleVT() == MVT::i64 && ToVT.getSimpleVT() == MVT::i32);
+}
+
+bool llvm::NVPTXTargetLowering::isZExtFree(EVT FromVT, EVT ToVT) const {
+ return (FromVT.getSimpleVT() == MVT::i32 && ToVT.getSimpleVT() == MVT::i64);
+}
+
// This creates target external symbol for a function parameter.
// Name of the symbol is composed from its index and the function name.
// Negative index corresponds to special parameter (unsized array) used for
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
index 13153f4830b695..57dc5b8fad4058 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
@@ -612,6 +612,10 @@ class NVPTXTargetLowering : public TargetLowering {
return true;
}
+ bool isTruncateFree(EVT FromVT, EVT ToVT) const override;
+
+ bool isZExtFree(EVT FromVT, EVT ToVT) const override;
+
private:
const NVPTXSubtarget &STI; // cache the subtarget here
SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
|
|
Could you please add some lit tests to this PR to demonstrate what the intended impact of this change is? |
|
|
You can test this locally with the following command:git-clang-format --diff b24650e814e55d90acfc40acf045456c98f32b9c 1361e2c072dc60162f5de0992d248eebd3156573 --extensions h,cpp -- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp llvm/lib/Target/NVPTX/NVPTXISelLowering.hView the diff from clang-format here.diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
index 57dc5b8fad..427deb4a65 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
@@ -612,9 +612,9 @@ public:
return true;
}
- bool isTruncateFree(EVT FromVT, EVT ToVT) const override;
+ bool isTruncateFree(EVT FromVT, EVT ToVT) const override;
- bool isZExtFree(EVT FromVT, EVT ToVT) const override;
+ bool isZExtFree(EVT FromVT, EVT ToVT) const override;
private:
const NVPTXSubtarget &STI; // cache the subtarget here
|
Implemented isTruncateFree and isZExtFree virtual functions in NVPTXTargetLowering to optimize i32/i64 truncation and zero-extension operations.