[llvm] [VP] Add method for looking up functional intrinsic ID for VP. NFC (PR #66190)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 04:56:48 PDT 2023
https://github.com/lukel97 updated https://github.com/llvm/llvm-project/pull/66190:
>From 834e5c556cc733ef4aae25f484a353b71634a7d3 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Wed, 13 Sep 2023 11:34:30 +0100
Subject: [PATCH 1/2] [VP] Add method for looking up functional intrinsic ID
for VP. NFC
This adds a helper method to get the ID of the functionally equivalent
intrinsic, similar to the existing getFunctionalOpcodeForVP and
getConstrainedIntrinsicIDForVP method.
It could potentially be used in #65706 to scalarize VP intrinsics.
---
llvm/include/llvm/IR/IntrinsicInst.h | 9 +++++++++
llvm/lib/IR/IntrinsicInst.cpp | 14 ++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 62bd833198f022b..83ab88252ac2feb 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -596,6 +596,11 @@ class VPIntrinsic : public IntrinsicInst {
return getFunctionalOpcodeForVP(getIntrinsicID());
}
+ // Equivalent non-predicated intrinsic ID
+ std::optional<unsigned> getFunctionalIntrinsicID() const {
+ return getFunctionalIntrinsicIDForVP(getIntrinsicID());
+ }
+
// Equivalent non-predicated constrained ID
std::optional<unsigned> getConstrainedIntrinsicID() const {
return getConstrainedIntrinsicIDForVP(getIntrinsicID());
@@ -604,6 +609,10 @@ class VPIntrinsic : public IntrinsicInst {
// Equivalent non-predicated opcode
static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
+ // Equivalent non-predicated intrinsic ID
+ static std::optional<unsigned>
+ getFunctionalIntrinsicIDForVP(Intrinsic::ID ID);
+
// Equivalent non-predicated constrained ID
static std::optional<unsigned>
getConstrainedIntrinsicIDForVP(Intrinsic::ID ID);
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 61be167ebaa28db..5e5a09d6dd50210 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -529,6 +529,20 @@ VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
return std::nullopt;
}
+// Equivalent non-predicated intrinsic
+std::optional<unsigned>
+VPIntrinsic::getFunctionalIntrinsicIDForVP(Intrinsic::ID ID) {
+ switch (ID) {
+ default:
+ break;
+#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
+#define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) return Intrinsic::INTRIN;
+#define END_REGISTER_VP_INTRINSIC(VPID) break;
+#include "llvm/IR/VPIntrinsics.def"
+ }
+ return std::nullopt;
+}
+
// Equivalent non-predicated constrained intrinsic
std::optional<unsigned>
VPIntrinsic::getConstrainedIntrinsicIDForVP(Intrinsic::ID ID) {
>From 25d52b8814e46827e8a7a180ff1e92d622b199c6 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Wed, 13 Sep 2023 12:54:12 +0100
Subject: [PATCH 2/2] Use Intrinsic::ID instead of unsigned
---
llvm/include/llvm/IR/IntrinsicInst.h | 4 ++--
llvm/lib/IR/IntrinsicInst.cpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 83ab88252ac2feb..338373f0338651c 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -610,11 +610,11 @@ class VPIntrinsic : public IntrinsicInst {
static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
// Equivalent non-predicated intrinsic ID
- static std::optional<unsigned>
+ static std::optional<Intrinsic::ID>
getFunctionalIntrinsicIDForVP(Intrinsic::ID ID);
// Equivalent non-predicated constrained ID
- static std::optional<unsigned>
+ static std::optional<Intrinsic::ID>
getConstrainedIntrinsicIDForVP(Intrinsic::ID ID);
};
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 5e5a09d6dd50210..c73634e5db06ab9 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -530,7 +530,7 @@ VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
}
// Equivalent non-predicated intrinsic
-std::optional<unsigned>
+std::optional<Intrinsic::ID>
VPIntrinsic::getFunctionalIntrinsicIDForVP(Intrinsic::ID ID) {
switch (ID) {
default:
@@ -544,7 +544,7 @@ VPIntrinsic::getFunctionalIntrinsicIDForVP(Intrinsic::ID ID) {
}
// Equivalent non-predicated constrained intrinsic
-std::optional<unsigned>
+std::optional<Intrinsic::ID>
VPIntrinsic::getConstrainedIntrinsicIDForVP(Intrinsic::ID ID) {
switch (ID) {
default:
More information about the llvm-commits
mailing list