[llvm] [NVPTX] Implemented istruncatefree and iszextfree alongwith test cases. (PR #115139)
Justin Fargnoli via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 10:43:14 PST 2024
================
@@ -506,6 +506,17 @@ class NVPTXTargetLowering : public TargetLowering {
DstTy->getPrimitiveSizeInBits() == 32;
}
+ bool isTruncateFree(EVT FromVT, EVT ToVT) const override {
+ if (!FromVT.isScalarInteger() || !ToVT.isScalarInteger()) {
+ return false;
+ }
+ return FromVT.getSizeInBits() == 64 && ToVT.getSizeInBits() == 32;
+ }
+
+ bool isZExtFree(EVT FromVT, EVT ToVT) const override { return false; }
+
+ bool isZExtFree(Type *SrcTy, Type *DstTy) const override { return false; }
----------------
justinfargnoli wrote:
I've asked around internally and have concluded that although `zext` may be cheap or possible to optimize away, it is *not* free in the general case.
So, the implementation you went with is correct. However, it isn't buying us anything because the [default behavior](https://github.com/llvm/llvm-project/blob/4d4024e1edf354113e8d0d11661d466ae5b0bee7/llvm/include/llvm/CodeGen/TargetLowering.h#L3046-L3060) is to return false.
Thus, let's delete the overrides and narrow the scope of this PR!
https://github.com/llvm/llvm-project/pull/115139
More information about the llvm-commits
mailing list