diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -2343,6 +2344,11 @@ TargetDAGCombineArray[NT >> 3] |= 1 << (NT&7); } + void setTargetDAGCombine(std::initializer_list NTs) { + for (auto NT : NTs) + setTargetDAGCombine(NT); + } + /// Set the target's minimum function alignment. void setMinFunctionAlignment(Align Alignment) { MinFunctionAlignment = Alignment; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -1031,39 +1031,22 @@ // Jumps are expensive, compared to logic setJumpIsExpensive(); - setTargetDAGCombine(ISD::ADD); - setTargetDAGCombine(ISD::SUB); - setTargetDAGCombine(ISD::AND); - setTargetDAGCombine(ISD::OR); - setTargetDAGCombine(ISD::XOR); - if (Subtarget.hasStdExtZbp()) { - setTargetDAGCombine(ISD::ROTL); - setTargetDAGCombine(ISD::ROTR); - } + setTargetDAGCombine({ISD::INTRINSIC_WO_CHAIN, ISD::ADD, ISD::SUB, ISD::AND, + ISD::OR, ISD::XOR}); + + if (Subtarget.hasStdExtZbp()) + setTargetDAGCombine({ISD::ROTL, ISD::ROTR}); if (Subtarget.hasStdExtZbkb()) setTargetDAGCombine(ISD::BITREVERSE); - setTargetDAGCombine(ISD::INTRINSIC_WO_CHAIN); if (Subtarget.hasStdExtZfh() || Subtarget.hasStdExtZbb()) setTargetDAGCombine(ISD::SIGN_EXTEND_INREG); - if (Subtarget.hasStdExtF()) { - setTargetDAGCombine(ISD::ZERO_EXTEND); - setTargetDAGCombine(ISD::FP_TO_SINT); - setTargetDAGCombine(ISD::FP_TO_UINT); - setTargetDAGCombine(ISD::FP_TO_SINT_SAT); - setTargetDAGCombine(ISD::FP_TO_UINT_SAT); - } - if (Subtarget.hasVInstructions()) { - setTargetDAGCombine(ISD::FCOPYSIGN); - setTargetDAGCombine(ISD::MGATHER); - setTargetDAGCombine(ISD::MSCATTER); - setTargetDAGCombine(ISD::VP_GATHER); - setTargetDAGCombine(ISD::VP_SCATTER); - setTargetDAGCombine(ISD::SRA); - setTargetDAGCombine(ISD::SRL); - setTargetDAGCombine(ISD::SHL); - setTargetDAGCombine(ISD::STORE); - setTargetDAGCombine(ISD::SPLAT_VECTOR); - } + if (Subtarget.hasStdExtF()) + setTargetDAGCombine({ISD::ZERO_EXTEND, ISD::FP_TO_SINT, ISD::FP_TO_UINT, + ISD::FP_TO_SINT_SAT, ISD::FP_TO_UINT_SAT}); + if (Subtarget.hasVInstructions()) + setTargetDAGCombine({ISD::FCOPYSIGN, ISD::MGATHER, ISD::MSCATTER, + ISD::VP_GATHER, ISD::VP_SCATTER, ISD::SRA, ISD::SRL, + ISD::SHL, ISD::STORE, ISD::SPLAT_VECTOR}); setLibcallName(RTLIB::FPEXT_F16_F32, "__extendhfsf2"); setLibcallName(RTLIB::FPROUND_F32_F16, "__truncsfhf2");