[llvm] [NVPTX] Add truncate and zero-extend free type conversions (PR #125580)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 16:19:11 PST 2025


================
@@ -150,6 +150,28 @@ class NVPTXTargetLowering : public TargetLowering {
            DstTy->getPrimitiveSizeInBits() == 32;
   }
 
+  bool isTruncateFree(EVT SrcVT, EVT DstVT) const override {
+    // Truncating from i64 to i32 is free
+    if (SrcVT.isInteger() && DstVT.isInteger())
+      return SrcVT.getSizeInBits() == 64 && DstVT.getSizeInBits() == 32;
+    return false;
----------------
justinfargnoli wrote:

```suggestion
    if (SrcVT.isInteger() && DstVT.isInteger())
      return false;
    return DstTy->getPrimitiveSizeInBits() % 32 == 0;
```

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


More information about the llvm-commits mailing list