diff --git a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp index f973e75840dc0..53557049ea33c 100644 --- a/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp +++ b/llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp @@ -847,13 +847,7 @@ static bool isSupportedInstr(const MachineInstr &MI) { case RISCV::VLUXEI32_V: case RISCV::VLOXEI32_V: case RISCV::VLUXEI64_V: - case RISCV::VLOXEI64_V: { - for (const MachineMemOperand *MMO : MI.memoperands()) - if (MMO->isVolatile()) - return false; - return true; - } - + case RISCV::VLOXEI64_V: // Vector Single-Width Integer Add and Subtract case RISCV::VADD_VI: case RISCV::VADD_VV: @@ -1292,6 +1286,13 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const { return false; } + for (const MachineMemOperand *MMO : MI.memoperands()) { + if (MMO->isVolatile()) { + LLVM_DEBUG(dbgs() << "Not a candidate because contains volatile MMO\n"); + return false; + } + } + // Some instructions that produce vectors have semantics that make it more // difficult to determine whether the VL can be reduced. For example, some // instructions, such as reductions, may write lanes past VL to a scalar