[llvm] [RISCV] Keep same SEW/LMUL ratio if possible in forward transfer (PR #69788)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 12:20:37 PDT 2023


================
@@ -1042,6 +1042,26 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info,
   if (!RISCVII::hasVLOp(TSFlags))
     return;
 
+  // If we don't use LMUL or the SEW/LMUL ratio, then adjust LMUL so that we
+  // maintain the SEW/LMUL ratio. This allows us to eliminate VL toggles in more
+  // places.
+  DemandedFields Demanded = getDemanded(MI, MRI);
+  if (!Demanded.LMUL && !Demanded.SEWLMULRatio && Info.isValid() &&
+      PrevInfo.isValid() && !Info.isUnknown() && !PrevInfo.isUnknown() &&
+      !Info.hasSameVLMAX(PrevInfo)) {
+    unsigned SEW = Info.getSEW();
+    // Fixed point value with 3 fractional bits.
----------------
preames wrote:

This looks very similar to getSameRatioLMUL, but with an extra bounds check.  Could we manage to share code somehow?  Maybe return an optional and handle the error case in MCA?  Since I think, at least in principle, the error case is possible there?

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


More information about the llvm-commits mailing list