[llvm] [RISCV][VLOPT] Enable the RISCVVLOptimizer by default (PR #119461)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 09:32:19 PST 2024


preames wrote:

Reading through the code, I spotted one potential correctness issue.  This is a cornercase, but probably still worth fixing.

Imagine you have the following:
%v = VADD_VV ...
%s = VREDSUM w/ %v as scalar source
%dead = VADD_VV %v, %v w/ VL=0

The last instruction is dead - it can be folded to it's passthru.  (In practice, it probably will have been folded, but it's possible something could slip through to here.)  However, when scaning the users of %v, we will decide that the correct VL for %v is 0 (or a register which might be zero), and reduce it below the minimum VL=1 required by the reduction.

To fix this, I believe you need to treat the CommonVL for the scalar operand case as being VL=1.  You could also track a non-zero state instead.  

Other than that, looks good to me.  Once you've fixed this issue, happy to approve.



https://github.com/llvm/llvm-project/pull/119461


More information about the llvm-commits mailing list