[llvm] [MachineVerifier] Fix bug in MachineVerifier for G_INSERT_SUBVECTOR (PR #109048)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 13:54:26 PDT 2024


https://github.com/michaelmaitland created https://github.com/llvm/llvm-project/pull/109048

None

>From 4d7938433122f7b9f538efee45995ac02a300c91 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Tue, 17 Sep 2024 13:39:53 -0700
Subject: [PATCH] [MachineVerifier] Fix bug in MachineVerifier for
 G_INSERT_SUBVECTOR

---
 llvm/lib/CodeGen/MachineVerifier.cpp                  | 2 +-
 llvm/test/MachineVerifier/test_g_insert_subvector.mir | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 6eed73c15f091d..1fcbeeec6f64cc 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1739,7 +1739,7 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
     }
 
     if (IndexOp.getImm() != 0 &&
-        Src1Ty.getElementCount().getKnownMinValue() % IndexOp.getImm() != 0) {
+        IndexOp.getImm() % Src1Ty.getElementCount().getKnownMinValue() != 0) {
       report("Index must be a multiple of the second source vector's "
              "minimum vector length",
              MI);
diff --git a/llvm/test/MachineVerifier/test_g_insert_subvector.mir b/llvm/test/MachineVerifier/test_g_insert_subvector.mir
index 9fce3c3e842d40..62ddd28919b205 100644
--- a/llvm/test/MachineVerifier/test_g_insert_subvector.mir
+++ b/llvm/test/MachineVerifier/test_g_insert_subvector.mir
@@ -41,4 +41,7 @@ body:             |
 
     ; CHECK: Index must be a multiple of the second source vector's minimum vector length
     %13:_(<vscale x 4 x s32>) = G_INSERT_SUBVECTOR %12, %1, 3
+
+    ; CHECK: Index must be a multiple of the second source vector's minimum vector length
+    %13:_(<vscale x 4 x s32>) = G_INSERT_SUBVECTOR %12, %1, 1
 ...



More information about the llvm-commits mailing list