[llvm] [NVPTX] Implement isTruncateFree and isZExtFree for i32/i64 Optimizations (PR #114601)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 13:28:25 PDT 2024
https://github.com/Quark-69 created https://github.com/llvm/llvm-project/pull/114601
Implemented isTruncateFree and isZExtFree virtual functions in NVPTXTargetLowering to optimize i32/i64 truncation and zero-extension operations.
>From 6d280b0d941fa3f6956d65d4894f54e470f3fcb3 Mon Sep 17 00:00:00 2001
From: UjjawalK7895 <ujjawal.kchouhan.ece23 at itbhu.ac.in>
Date: Sat, 2 Nov 2024 01:46:31 +0530
Subject: [PATCH] Implemented isTruncateFree(EVT FromVT, EVT ToVT) and
isZExtFree(EVT FromVT, EVT ToVT) in NVPTX.
---
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | 8 ++++++++
llvm/lib/Target/NVPTX/NVPTXISelLowering.h | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
index 379a4a77647079..2f2f204d0d36f8 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -3285,6 +3285,14 @@ bool NVPTXTargetLowering::splitValueIntoRegisterParts(
return false;
}
+bool llvm::NVPTXTargetLowering::isTruncateFree(EVT FromVT, EVT ToVT) const {
+ return (FromVT.getSimpleVT() == MVT::i64 && ToVT.getSimpleVT() == MVT::i32);
+}
+
+bool llvm::NVPTXTargetLowering::isZExtFree(EVT FromVT, EVT ToVT) const {
+ return (FromVT.getSimpleVT() == MVT::i32 && ToVT.getSimpleVT() == MVT::i64);
+}
+
// This creates target external symbol for a function parameter.
// Name of the symbol is composed from its index and the function name.
// Negative index corresponds to special parameter (unsized array) used for
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
index 13153f4830b695..57dc5b8fad4058 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h
@@ -612,6 +612,10 @@ class NVPTXTargetLowering : public TargetLowering {
return true;
}
+ bool isTruncateFree(EVT FromVT, EVT ToVT) const override;
+
+ bool isZExtFree(EVT FromVT, EVT ToVT) const override;
+
private:
const NVPTXSubtarget &STI; // cache the subtarget here
SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
More information about the llvm-commits
mailing list