From 5a19fbad83018b705923e13fee957c049c295bbf Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 14 May 2022 13:44:55 -0700 Subject: [PATCH] [RISCV] Remove unneeded check for ISD::VSCALE operand being a constant. NFC ISD::VSCALE only allows constant operands. --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 36 ++++++++++----------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 392594c27a91..8894fc4e2026 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -3097,26 +3097,24 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op, static_assert(RISCV::RVVBitsPerBlock == 64, "Unexpected bits per block!"); if (Subtarget.getMinVLen() < RISCV::RVVBitsPerBlock) report_fatal_error("Support for VLEN==32 is incomplete."); - if (isa(Op.getOperand(0))) { - // We assume VLENB is a multiple of 8. We manually choose the best shift - // here because SimplifyDemandedBits isn't always able to simplify it. - uint64_t Val = Op.getConstantOperandVal(0); - if (isPowerOf2_64(Val)) { - uint64_t Log2 = Log2_64(Val); - if (Log2 < 3) - return DAG.getNode(ISD::SRL, DL, VT, VLENB, - DAG.getConstant(3 - Log2, DL, VT)); - if (Log2 > 3) - return DAG.getNode(ISD::SHL, DL, VT, VLENB, - DAG.getConstant(Log2 - 3, DL, VT)); - return VLENB; - } - // If the multiplier is a multiple of 8, scale it down to avoid needing - // to shift the VLENB value. - if ((Val % 8) == 0) - return DAG.getNode(ISD::MUL, DL, VT, VLENB, - DAG.getConstant(Val / 8, DL, VT)); + // We assume VLENB is a multiple of 8. We manually choose the best shift + // here because SimplifyDemandedBits isn't always able to simplify it. + uint64_t Val = Op.getConstantOperandVal(0); + if (isPowerOf2_64(Val)) { + uint64_t Log2 = Log2_64(Val); + if (Log2 < 3) + return DAG.getNode(ISD::SRL, DL, VT, VLENB, + DAG.getConstant(3 - Log2, DL, VT)); + if (Log2 > 3) + return DAG.getNode(ISD::SHL, DL, VT, VLENB, + DAG.getConstant(Log2 - 3, DL, VT)); + return VLENB; } + // If the multiplier is a multiple of 8, scale it down to avoid needing + // to shift the VLENB value. + if ((Val % 8) == 0) + return DAG.getNode(ISD::MUL, DL, VT, VLENB, + DAG.getConstant(Val / 8, DL, VT)); SDValue VScale = DAG.getNode(ISD::SRL, DL, VT, VLENB, DAG.getConstant(3, DL, VT));