[llvm] [NVPTX] Implement `isTruncateFree(EVT FromVT, EVT ToVT)` (PR #138605)
Kevin McAfee via llvm-commits
llvm-commits at lists.llvm.org
Mon May 5 17:54:20 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;
----------------
kalxr wrote:
I believe so. The second condition is explicitly mentioned in https://github.com/llvm/llvm-project/blob/1c1238d3615a7e1a99570d1e02de3b538d2e0669/llvm/include/llvm/CodeGen/TargetLowering.h#L3025. Most targets that override this have a check for the first condition as well.
https://github.com/llvm/llvm-project/pull/138605
More information about the llvm-commits
mailing list