[llvm] a969239 - [RISCV] Move volatile check to isCandidate in VL optimizer. NFC (#154685)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 21 01:37:14 PDT 2025
Author: Luke Lau
Date: 2025-08-21T16:37:10+08:00
New Revision: a9692391f60f7e4ff8df4f96ea5fa7cc5d12c2ce
URL: https://github.com/llvm/llvm-project/commit/a9692391f60f7e4ff8df4f96ea5fa7cc5d12c2ce
DIFF: https://github.com/llvm/llvm-project/commit/a9692391f60f7e4ff8df4f96ea5fa7cc5d12c2ce.diff
LOG: [RISCV] Move volatile check to isCandidate in VL optimizer. NFC (#154685)
This keeps it closer to the other legality checks like the FP exceptions
check.
It also means that isSupportedInstr only needs to check the opcode,
which allows it to be replaced with a TSFlags based check in a later
patch.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp
Removed:
################################################################################
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
//
diff icult to determine whether the VL can be reduced. For example, some
// instructions, such as reductions, may write lanes past VL to a scalar
More information about the llvm-commits
mailing list