[llvm] [RISCV] Don't run insertVSETMTK if +xsfmmbase isn't present (PR #206426)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 01:12:57 PDT 2026
https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/206426
I'm not familiar with xsfmmbase but IIUC we don't need to run those passes if the extension isn't present, so this saves some compile time when the feature isn't enabled.
Some tests were missing the sifive-O0-ATM-ATK.ll extension so I've added the feature, which caused one of the vsetvlis to turn into a sf.vsettnt
>From daca868280150ff4a9e5c932a7325807031f7f76 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 29 Jun 2026 16:09:10 +0800
Subject: [PATCH] [RISCV] Don't run insertVSETMTK if +xsfmmbase isn't present
I'm not familiar with xsfmmbase but IIUC we don't need to run those passes if the extension isn't present, so this saves some compile time when the feature isn't enabled.
Some tests were missing the sifive-O0-ATM-ATK.ll extension so I've added the feature, which caused one of the vsetvlis to turn into a sf.vsettnt
---
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 8 +++++---
llvm/test/CodeGen/RISCV/rvv/sifive-O0-ATM-ATK.ll | 4 ++--
llvm/test/CodeGen/RISCV/rvv/sifive-xsfmm-vset-insert.mir | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index f964979baa412..0455c28774a8e 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -1094,9 +1094,11 @@ bool RISCVInsertVSETVLI::runOnMachineFunction(MachineFunction &MF) {
for (MachineBasicBlock &MBB : MF)
insertReadVL(MBB);
- for (MachineBasicBlock &MBB : MF) {
- insertVSETMTK(MBB, VSETTM);
- insertVSETMTK(MBB, VSETTK);
+ if (ST->hasVendorXSfmmbase()) {
+ for (MachineBasicBlock &MBB : MF) {
+ insertVSETMTK(MBB, VSETTM);
+ insertVSETMTK(MBB, VSETTK);
+ }
}
BlockInfo.clear();
diff --git a/llvm/test/CodeGen/RISCV/rvv/sifive-O0-ATM-ATK.ll b/llvm/test/CodeGen/RISCV/rvv/sifive-O0-ATM-ATK.ll
index 1bd966ef7e481..2fe64c71fe5f6 100644
--- a/llvm/test/CodeGen/RISCV/rvv/sifive-O0-ATM-ATK.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/sifive-O0-ATM-ATK.ll
@@ -1,11 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=riscv64 -mattr=+v -O0 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK-RV64
+; RUN: llc -mtriple=riscv64 -mattr=+v,+xsfmmbase -O0 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK-RV64
define void @matmul() {
; CHECK-RV64-LABEL: matmul:
; CHECK-RV64: # %bb.0: # %entry
; CHECK-RV64-NEXT: li a0, 0
-; CHECK-RV64-NEXT: vsetvli zero, a0, 512
+; CHECK-RV64-NEXT: sf.vsettnt zero, a0, e8, w1
; CHECK-RV64-NEXT: sf.vsettm zero, a0
; CHECK-RV64-NEXT: sf.vtzero.t mt0
; CHECK-RV64-NEXT: ret
diff --git a/llvm/test/CodeGen/RISCV/rvv/sifive-xsfmm-vset-insert.mir b/llvm/test/CodeGen/RISCV/rvv/sifive-xsfmm-vset-insert.mir
index 3faf5f51b6b84..202b051114649 100644
--- a/llvm/test/CodeGen/RISCV/rvv/sifive-xsfmm-vset-insert.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/sifive-xsfmm-vset-insert.mir
@@ -1,5 +1,5 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-# RUN: llc %s -o - -mtriple=riscv64 -mattr=+v \
+# RUN: llc %s -o - -mtriple=riscv64 -mattr=+v,+xsfmmbase \
# RUN: -run-pass=phi-node-elimination,register-coalescer,riscv-insert-vsetvli | FileCheck %s
--- |
More information about the llvm-commits
mailing list