[llvm] [NVPTX] Implement `isTruncateFree(EVT FromVT, EVT ToVT)` (PR #138605)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 09:53:50 PDT 2025


================
@@ -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;
----------------
justinfargnoli wrote:

Yeah, that's a good point. When expressed in PTX, the vectors become registers and thus do not guarantee contiguousness. 

https://github.com/llvm/llvm-project/pull/138605


More information about the llvm-commits mailing list