[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;
+ }
+
+ 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:
I'm no longer confident that `zext` is free in this case.
In [this simple example](https://godbolt.org/z/b77hd3f5s) an instruction is issued to zero out `R3`. Are there counter-examples that show why it is free?
https://github.com/llvm/llvm-project/pull/125580
More information about the llvm-commits
mailing list