Skip to content

Conversation

@SergeantCooper
Copy link

Implemented isTruncateFree and isZExtFree virtual functions in NVPTXTargetLowering to optimize i32/i64 truncation and zero-extension operations.

@github-actions
Copy link

github-actions bot commented Nov 1, 2024

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 @ followed by their GitHub username.

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.

@llvmbot
Copy link
Member

llvmbot commented Nov 1, 2024

@llvm/pr-subscribers-backend-nvptx

Author: None (Quark-69)

Changes

Implemented 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:

  • (modified) llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp (+8)
  • (modified) llvm/lib/Target/NVPTX/NVPTXISelLowering.h (+4)
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;

@AlexMaclean
Copy link
Member

Could you please add some lit tests to this PR to demonstrate what the intended impact of this change is?

@github-actions
Copy link

github-actions bot commented Nov 1, 2024

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

@github-actions
Copy link

github-actions bot commented Nov 1, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

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.h
View 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants