[llvm] [GISEL] Fix bug in G_EXTRACT_SUBVECTOR definition (PR #108848)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 08:48:27 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-globalisel

Author: Michael Maitland (michaelmaitland)

<details>
<summary>Changes</summary>

The implementation was missing the fact that `G_EXTRACT_SUBVECTOR` destination and source vector can be different types.

---
Full diff: https://github.com/llvm/llvm-project/pull/108848.diff


2 Files Affected:

- (modified) llvm/include/llvm/Target/GenericOpcodes.td (+1-1) 
- (modified) llvm/test/MachineVerifier/test_g_extract_subvector.mir (+3) 


``````````diff
diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td
index a55d9d3b04e62f..f5e62dda6fd043 100644
--- a/llvm/include/llvm/Target/GenericOpcodes.td
+++ b/llvm/include/llvm/Target/GenericOpcodes.td
@@ -1541,7 +1541,7 @@ def G_INSERT_SUBVECTOR : GenericInstruction {
 // Generic extract subvector.
 def G_EXTRACT_SUBVECTOR : GenericInstruction {
   let OutOperandList = (outs type0:$dst);
-  let InOperandList = (ins type0:$src, untyped_imm_0:$idx);
+  let InOperandList = (ins type1:$src, untyped_imm_0:$idx);
   let hasSideEffects = false;
 }
 
diff --git a/llvm/test/MachineVerifier/test_g_extract_subvector.mir b/llvm/test/MachineVerifier/test_g_extract_subvector.mir
index 5a441ff29c1721..3414843084e8a8 100644
--- a/llvm/test/MachineVerifier/test_g_extract_subvector.mir
+++ b/llvm/test/MachineVerifier/test_g_extract_subvector.mir
@@ -29,4 +29,7 @@ body:             |
 
     ; CHECK: Index must be a multiple of the source vector's minimum vector length
     %9:_(<vscale x 4 x s32>) = G_EXTRACT_SUBVECTOR  %1, 3
+
+    ; CHECK-NOT: Type mismatch in generic instruction
+    %10:_(<vscale x 4 x s32>) = G_EXTRACT_SUBVECTOR  %1, 2
 ...

``````````

</details>


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


More information about the llvm-commits mailing list