[llvm] [RISCV][VLOPT] Don't reduce the VL is the same as CommonVL (PR #123878)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 22 07:42:19 PST 2025
================
@@ -1314,8 +1314,8 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &OrigMI) {
unsigned VLOpNum = RISCVII::getVLOpNum(MI.getDesc());
MachineOperand &VLOp = MI.getOperand(VLOpNum);
- if (!RISCV::isVLKnownLE(*CommonVL, VLOp)) {
- LLVM_DEBUG(dbgs() << " Abort due to CommonVL not <= VLOp.\n");
+ if (!RISCV::isVLKnownLT(*CommonVL, VLOp)) {
+ LLVM_DEBUG(dbgs() << " Abort due to CommonVL not < VLOp.\n");
continue;
}
----------------
preames wrote:
Luke's suggestion allows an infinite loop if we somehow ended up with two VL values which were not identical, but represented equal VLs. We can reduce to A, then reduce to B, then reduce to A, then B... In principal, this could happen for two different register values which had the same runtime value. I don't believe the current comparison logic makes this possible, but it would be a foot gun for the future.
I prefer @michaelmaitland 's original framing since it guarantees termination.
Note that we could use the isIdenticalTo check in the implementation of the LT operator if we wanted. This is more of an API design comment then an implementation one.
https://github.com/llvm/llvm-project/pull/123878
More information about the llvm-commits
mailing list