<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64071>64071</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] test-match-reduction failed with assertion failure "Invalid index!"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Colloportus0
      </td>
    </tr>
</table>

<pre>
    MLIR built at commit  585cbe3f
Reproduced with:  
`mlir-opt -pass-pipeline='builtin.module(func.func(test-match-reduction))' temp.mlir`

temp.mlir:
``` milr 
module { 
  func.func @func2(%arg0: tensor<?x?x?xi1>, %arg1: tensor<5x5xi32>) {
    %c9777_i16 = arith.constant 9777 : i16
    %c-3527_i16 = arith.constant -3527 : i16
 %c2 = arith.constant 2 : index 
    %18 = index.ceildivu %c2, %c2
 %28 = index.ceildivu %c2, %c2
    %43 = index.sizeof
    %46 = index.divs %c2, %c2
    %92 = affine.apply affine_map<(d0, d1, d2, d3) -> (d0 - 16)>(%46, %28, %c2, %43)
    scf.index_switch %92 
    default {
      %136 = scf.index_switch %c2 -> memref<23x8xi1> 
      default {
        %147 = tensor.empty() : tensor<7xi16>
        %148 = tensor.empty() : tensor<i16>
        %149 = linalg.dot ins(%147, %147 : tensor<7xi16>, tensor<7xi16>) outs(%148 : tensor<i16>) -> tensor<i16>
 %alloc_37 = memref.alloc() : memref<23x8xi1>
        scf.yield %alloc_37 : memref<23x8xi1>
      }
    } 
    return
 }
}

```
 
trace:
```console
Assertion failed: (Index < this->size() && "Invalid index!"), function operator[], file ArrayRef.h, line 441.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: mlir-opt -pass-pipeline=builtin.module(func.func(test-match-reduction)) temp.mlir
 #0 0x00000001030ecf18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8f18)
 #1 0x00000001030eb1b4 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f71b4)
 #2 0x00000001030ed5c4 SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f95c4)
 #3 0x00000001be7894c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
 #4 0x00000001be771ee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
 #5 0x00000001be6ac340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
 #6 0x00000001be6ab754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
 #7 0x000000010769f674 mlir::matchReduction(llvm::ArrayRef<mlir::BlockArgument>, unsigned int, llvm::SmallVectorImpl<mlir::Operation*>&) (.cold.5) (/workspace/build/bin/mlir-opt+0x1048ab674)
 #8 0x000000010571f824 mlir::matchReduction(llvm::ArrayRef<mlir::BlockArgument>, unsigned int, llvm::SmallVectorImpl<mlir::Operation*>&) (/workspace/build/bin/mlir-opt+0x10292b824)
 #9 0x000000010523a7c4 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::TestMatchReductionPass::runOnOperation()::'lambda'(mlir::Operation*)>(long, mlir::Operation*) (/workspace/build/bin/mlir-opt+0x1024467c4)
#10 0x000000010348a2b8 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x1006962b8)
#11 0x000000010348a32c void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x10069632c)
#12 0x000000010348a32c void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x10069632c)
#13 0x000000010348a32c void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x10069632c)
#14 0x000000010523a5c8 (anonymous namespace)::TestMatchReductionPass::runOnOperation() (/workspace/build/bin/mlir-opt+0x1024465c8)
#15 0x000000010573c2a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x1029482a8)
#16 0x000000010573c998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#17 0x000000010573da4c mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/workspace/build/bin/mlir-opt+0x102949a4c)
#18 0x000000010573c404 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x102948404)
#19 0x000000010573c998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#20 0x000000010573e82c mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x10294a82c)
#21 0x0000000105736d14 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102942d14)
#22 0x0000000105736368 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x102942368)
#23 0x00000001057b434c mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/workspace/build/bin/mlir-opt+0x1029c034c)
#24 0x0000000105730d1c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10293cd1c)
#25 0x000000010573118c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x10293d18c)
#26 0x0000000102df7510 main (/workspace/build/bin/mlir-opt+0x100003510)
#27 0x000000010e5e9088 

``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt1u2zoSfhrmhoghkdTfRS5cJ8EGaJAgPdi9NCiSsrmhRC1JNfE-_YKUHJuO3TY-ZxdFt0XqH3E48803wxlSMrVWrjohrkD2CWTXF3Rwa22uFlop3WvjBptc1Jpvru4_3z3BepDKQeog020rHYRZmbFa4AYk1yCZP4neaD4wweGLdGuA5xCOIyBPWiXNpe4dvOyptZe97IWSnQD4GqAiKJbdrNV8UAKgshk6NvMvAJVOWHfZUsfWl0bwgTmpO4Cq8FdAJ9p-5pWDPJmMhdfddTx_AzH-wVYqMyEbLUJQfJouQPhmGwKS-HcEUAlQRs0q8T450VltAF4AfPu6_S9TgG8AWsBRMI0Es9fsVWIUJCpva2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