From c6d3347e137665cce111ee4890bac092005859e5 Mon Sep 17 00:00:00 2001 From: Jianjian GUAN Date: Tue, 23 May 2023 11:44:08 +0800 Subject: [PATCH] [RISCV][NFC] Simplify code. Reduce scope of if-else statements. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D151178 --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 97119e8..87784be 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -264,25 +264,19 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM, setLibcallName(RTLIB::MULO_I64, nullptr); } - if (!Subtarget.hasStdExtM() && !Subtarget.hasStdExtZmmul()) { + if (!Subtarget.hasStdExtM() && !Subtarget.hasStdExtZmmul()) setOperationAction({ISD::MUL, ISD::MULHS, ISD::MULHU}, XLenVT, Expand); - } else { - if (Subtarget.is64Bit()) { - setOperationAction(ISD::MUL, {MVT::i32, MVT::i128}, Custom); - } else { - setOperationAction(ISD::MUL, MVT::i64, Custom); - } - } + else if (Subtarget.is64Bit()) + setOperationAction(ISD::MUL, {MVT::i32, MVT::i128}, Custom); + else + setOperationAction(ISD::MUL, MVT::i64, Custom); - if (!Subtarget.hasStdExtM()) { + if (!Subtarget.hasStdExtM()) setOperationAction({ISD::SDIV, ISD::UDIV, ISD::SREM, ISD::UREM}, XLenVT, Expand); - } else { - if (Subtarget.is64Bit()) { - setOperationAction({ISD::SDIV, ISD::UDIV, ISD::UREM}, - {MVT::i8, MVT::i16, MVT::i32}, Custom); - } - } + else if (Subtarget.is64Bit()) + setOperationAction({ISD::SDIV, ISD::UDIV, ISD::UREM}, + {MVT::i8, MVT::i16, MVT::i32}, Custom); setOperationAction( {ISD::SDIVREM, ISD::UDIVREM, ISD::SMUL_LOHI, ISD::UMUL_LOHI}, XLenVT, -- 2.7.4