diff --git a/llvm/lib/Target/VE/VECustomDAG.h b/llvm/lib/Target/VE/VECustomDAG.h --- a/llvm/lib/Target/VE/VECustomDAG.h +++ b/llvm/lib/Target/VE/VECustomDAG.h @@ -21,6 +21,10 @@ namespace llvm { +Optional getVVPOpcode(unsigned Opcode); + +bool isVVPBinaryOp(unsigned Opcode); + class VECustomDAG { SelectionDAG &DAG; SDLoc DL; diff --git a/llvm/lib/Target/VE/VECustomDAG.cpp b/llvm/lib/Target/VE/VECustomDAG.cpp --- a/llvm/lib/Target/VE/VECustomDAG.cpp +++ b/llvm/lib/Target/VE/VECustomDAG.cpp @@ -19,6 +19,31 @@ namespace llvm { +/// \returns the VVP_* SDNode opcode corresponsing to \p OC. +Optional getVVPOpcode(unsigned Opcode) { + switch (Opcode) { +#define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \ + case ISD::VPOPC: \ + return VEISD::VVPNAME; +#define ADD_VVP_OP(VVPNAME, SDNAME) \ + case VEISD::VVPNAME: \ + case ISD::SDNAME: \ + return VEISD::VVPNAME; +#include "VVPNodes.def" + } + return None; +} + +bool isVVPBinaryOp(unsigned VVPOpcode) { + switch (VVPOpcode) { +#define ADD_BINARY_VVP_OP(VVPNAME, ...) \ + case VEISD::VVPNAME: \ + return true; +#include "VVPNodes.def" + } + return false; +} + SDValue VECustomDAG::getConstant(uint64_t Val, EVT VT, bool IsTarget, bool IsOpaque) const { return DAG.getConstant(Val, DL, VT, IsTarget, IsOpaque); diff --git a/llvm/lib/Target/VE/VEISelLowering.cpp b/llvm/lib/Target/VE/VEISelLowering.cpp --- a/llvm/lib/Target/VE/VEISelLowering.cpp +++ b/llvm/lib/Target/VE/VEISelLowering.cpp @@ -2667,21 +2667,6 @@ return true; } -/// \returns the VVP_* SDNode opcode corresponsing to \p OC. -static Optional getVVPOpcode(unsigned Opcode) { - switch (Opcode) { -#define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \ - case ISD::VPOPC: \ - return VEISD::VVPNAME; -#define ADD_VVP_OP(VVPNAME, SDNAME) \ - case VEISD::VVPNAME: \ - case ISD::SDNAME: \ - return VEISD::VVPNAME; -#include "VVPNodes.def" - } - return None; -} - SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const { // Can we represent this as a VVP node. const unsigned Opcode = Op->getOpcode(); @@ -2715,22 +2700,12 @@ ConstTrue); // emit a VEISD::VEC_BROADCAST here. } - // Categories we are interested in. - bool IsBinaryOp = false; - - switch (VVPOpcode) { -#define ADD_BINARY_VVP_OP(VVPNAME, ...) \ - case VEISD::VVPNAME: \ - IsBinaryOp = true; \ - break; -#include "VVPNodes.def" - } - - if (IsBinaryOp) { + if (isVVPBinaryOp(VVPOpcode)) { assert(LegalVecVT.isSimple()); return CDAG.getNode(VVPOpcode, LegalVecVT, {Op->getOperand(0), Op->getOperand(1), Mask, AVL}); - } else if (VVPOpcode == VEISD::VVP_SELECT) { + } + if (VVPOpcode == VEISD::VVP_SELECT) { auto Mask = Op->getOperand(0); auto OnTrue = Op->getOperand(1); auto OnFalse = Op->getOperand(2);