[llvm] [RISCV] Check that VLMAX is the same when demanding exact VL (PR #89080)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 07:40:00 PDT 2024


https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/89080

Currently we just check the AVL is the same, but if the AVL is larger than VLMAX then the VL may differ. We need to also check that the VLMAX (a.k.a the SEW/LMUL ratio) is also the same.

This doesn't seem to be a problem in practice beacause coincidentally we only demanded VLAny whenever we also demand SEWLMULRatio, see getDemanded. So I don't think it's possible to create a test case.


>From 1d4370610d07476133bc147d3af677ee918c95cf Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Wed, 17 Apr 2024 22:29:29 +0800
Subject: [PATCH] [RISCV] Check that VLMAX is the same when demanding exact VL

Currently we just check the AVL is the same, but if the AVL is larger than VLMAX then the VL may differ. We need to also check that the VLMAX (a.k.a the SEW/LMUL ratio) is also the same.

This doesn't seem to be a problem in practice beacause coincidentally we only demanded VLAny whenever we also demand SEWLMULRatio, see getDemanded. So I don't think it's possible to create a test case.
---
 llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index fa37d1ccccd737..331253e39c0acb 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -616,7 +616,7 @@ class VSETVLIInfo {
     if (SEWLMULRatioOnly)
       return false;
 
-    if (Used.VLAny && !hasSameAVL(Require))
+    if (Used.VLAny && !(hasSameAVL(Require) && hasSameVLMAX(Require)))
       return false;
 
     if (Used.VLZeroness && !hasEquallyZeroAVL(Require, MRI))



More information about the llvm-commits mailing list