Skip to content

Commit 41eb82f

Browse files
authored
[VP] Add method for looking up functional intrinsic ID for VP. NFC (#66190)
This adds a helper method to get the ID of the functionally equivalent intrinsic, similar to the existing getFunctionalOpcodeForVP and getConstrainedIntrinsicIDForVP methods. Not sure if it's notable or not, but I can't find any existing uses of VP_PROPERTY_FUNCTIONAL_INTRINSIC? It could potentially be used in #65706 to scalarize VP intrinsics.
1 parent 05a11f3 commit 41eb82f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ class VPIntrinsic : public IntrinsicInst {
596596
return getFunctionalOpcodeForVP(getIntrinsicID());
597597
}
598598

599+
// Equivalent non-predicated intrinsic ID
600+
std::optional<unsigned> getFunctionalIntrinsicID() const {
601+
return getFunctionalIntrinsicIDForVP(getIntrinsicID());
602+
}
603+
599604
// Equivalent non-predicated constrained ID
600605
std::optional<unsigned> getConstrainedIntrinsicID() const {
601606
return getConstrainedIntrinsicIDForVP(getIntrinsicID());
@@ -604,8 +609,12 @@ class VPIntrinsic : public IntrinsicInst {
604609
// Equivalent non-predicated opcode
605610
static std::optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
606611

612+
// Equivalent non-predicated intrinsic ID
613+
static std::optional<Intrinsic::ID>
614+
getFunctionalIntrinsicIDForVP(Intrinsic::ID ID);
615+
607616
// Equivalent non-predicated constrained ID
608-
static std::optional<unsigned>
617+
static std::optional<Intrinsic::ID>
609618
getConstrainedIntrinsicIDForVP(Intrinsic::ID ID);
610619
};
611620

llvm/lib/IR/IntrinsicInst.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,22 @@ VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
529529
return std::nullopt;
530530
}
531531

532+
// Equivalent non-predicated intrinsic
533+
std::optional<Intrinsic::ID>
534+
VPIntrinsic::getFunctionalIntrinsicIDForVP(Intrinsic::ID ID) {
535+
switch (ID) {
536+
default:
537+
break;
538+
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
539+
#define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) return Intrinsic::INTRIN;
540+
#define END_REGISTER_VP_INTRINSIC(VPID) break;
541+
#include "llvm/IR/VPIntrinsics.def"
542+
}
543+
return std::nullopt;
544+
}
545+
532546
// Equivalent non-predicated constrained intrinsic
533-
std::optional<unsigned>
547+
std::optional<Intrinsic::ID>
534548
VPIntrinsic::getConstrainedIntrinsicIDForVP(Intrinsic::ID ID) {
535549
switch (ID) {
536550
default:

0 commit comments

Comments
 (0)