[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:12 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;
+ }
+
+ bool isZExtFree(EVT FromVT, EVT ToVT) const override {
+ // Zero-extending from i32 to i64 is free
+ if (FromVT.isInteger() && ToVT.isInteger())
+ return FromVT.getSizeInBits() == 32 && ToVT.getSizeInBits() == 64;
+ return false;
+ }
+
+ bool isZExtFree(Type *SrcTy, Type *DstTy) const override {
+ // Zero-extending from i32 to i64 is free
+ if (SrcTy->isIntegerTy() && DstTy->isIntegerTy())
+ return SrcTy->getPrimitiveSizeInBits() == 32 &&
+ DstTy->getPrimitiveSizeInBits() == 64;
+ return false;
+ }
----------------
justinfargnoli wrote:
Can we write a test for this code?
https://github.com/llvm/llvm-project/pull/125580
More information about the llvm-commits
mailing list