[Mlir-commits] [mlir] [mlir][linalg] Fix UBSan division-by-zero in PackOp folding (PR #186271)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 25 06:02:13 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results

* 3575 tests passed
* 415 tests skipped
* 1 test failed

## Failed Tests
(click on a test name to see its output)

### MLIR
<details>
<summary>MLIR.Dialect/Linalg/canonicalize.mlir</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\mlir-opt.exe C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir -canonicalize="test-convergence" -split-input-file | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\mlir-opt.exe' 'C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir' -canonicalize=test-convergence -split-input-file
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1737:13: error: 'linalg.pack' op invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set
# |   %packed = linalg.pack %t inner_dims_pos = [0, 1] inner_tiles = [%tile1, %tile2] into %tensor_empty : tensor<128x128xf32> -> tensor<16x16x?x?xf32>
# |             ^
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1737:13: note: see current operation: %1 = "linalg.pack"(%arg0, %0, %arg1, %arg2) <{inner_dims_pos = array<i64: 0, 1>, operandSegmentSizes = array<i32: 1, 1, 0, 2>, static_inner_tiles = array<i64: -9223372036854775808, -9223372036854775808>}> : (tensor<128x128xf32>, tensor<16x16x?x?xf32>, index, index) -> tensor<16x16x?x?xf32>
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1767:13: error: 'linalg.pack' op invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set
# |   %packed = linalg.pack %unpacked inner_dims_pos = [0, 1] inner_tiles = [%tile1, %tile2] into %tensor_empty1 : tensor<128x128xf32> -> tensor<16x16x?x?xf32>
# |             ^
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1767:13: note: see current operation: %3 = "linalg.pack"(%1, %2, %arg1, %arg2) <{inner_dims_pos = array<i64: 0, 1>, operandSegmentSizes = array<i32: 1, 1, 0, 2>, static_inner_tiles = array<i64: -9223372036854775808, -9223372036854775808>}> : (tensor<128x128xf32>, tensor<16x16x?x?xf32>, index, index) -> tensor<16x16x?x?xf32>
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1837:13: error: 'linalg.pack' op invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set
# |   %packed = linalg.pack %unpacked outer_dims_perm = [0, 1] inner_dims_pos = [0, 1] inner_tiles = [%tile1, %tile2] into %tensor_empty1 : tensor<128x128xf32> -> tensor<16x16x?x?xf32>
# |             ^
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1837:13: note: see current operation: %3 = "linalg.pack"(%1, %2, %arg1, %arg2) <{inner_dims_pos = array<i64: 0, 1>, operandSegmentSizes = array<i32: 1, 1, 0, 2>, outer_dims_perm = array<i64: 0, 1>, static_inner_tiles = array<i64: -9223372036854775808, -9223372036854775808>}> : (tensor<128x128xf32>, tensor<16x16x?x?xf32>, index, index) -> tensor<16x16x?x?xf32>
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1850:13: error: 'linalg.pack' op invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set
# |   %packed = linalg.pack %unpacked inner_dims_pos = [0, 1] inner_tiles = [%tile1, %tile2] into %tensor_empty1 : tensor<128x128xf32> -> tensor<16x16x?x?xf32>
# |             ^
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1850:13: note: see current operation: %3 = "linalg.pack"(%1, %2, %arg1, %arg2) <{inner_dims_pos = array<i64: 0, 1>, operandSegmentSizes = array<i32: 1, 1, 0, 2>, static_inner_tiles = array<i64: -9223372036854775808, -9223372036854775808>}> : (tensor<128x128xf32>, tensor<16x16x?x?xf32>, index, index) -> tensor<16x16x?x?xf32>
# `-----------------------------
# error: command failed with exit status: 1
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:1732:11: error: CHECK: expected string not found in input
# | // CHECK: func.func @unpack_pack(
# |           ^
# | <stdin>:929:52: note: scanning from here
# |  func.func @unpack_pack(%arg0: tensor<128x128xf32>) -> tensor<128x128xf32> {
# |                                                    ^
# | <stdin>:953:2: note: possible intended match here
# |  func.func @pack_unpack(%arg0: tensor<16x16x8x8xf32>) -> tensor<16x16x8x8xf32> {
# |  ^
# | C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir:2119:17: error: CHECK-LABEL: expected string not found in input
# | // CHECK-LABEL: func @no_fold_extract_slice_into_unpack_slice_over_dynamic_dim
# |                 ^
# | <stdin>:1086:77: note: scanning from here
# |  func.func @negative_fold_extract_slice_into_unpack_slice_over_non_tiled_dim(%arg0: tensor<30x2x16xf32>, %arg1: tensor<30x32xf32>) -> tensor<28x28xf32> {
# |                                                                             ^
# | <stdin>:1095:13: note: possible intended match here
# |  func.func @negative_fold_extract_slice_into_unpack_slice_over_dynamic_dim(%arg0: tensor<?x2x16xf32>, %arg1: tensor<?x32xf32>, %arg2: index) -> tensor<?x28xf32> {
# |             ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\mlir\test\Dialect\Linalg\canonicalize.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |               .
# |               .
# |               .
# |             924:  } 
# |             925: } 
# |             926:  
# |             927: // ----- 
# |             928: module { 
# |             929:  func.func @unpack_pack(%arg0: tensor<128x128xf32>) -> tensor<128x128xf32> { 
# | check:1732'0                                                        X~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |             930:  %0 = tensor.empty() : tensor<16x16x8x8xf32> 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             931:  %pack = linalg.pack %arg0 outer_dims_perm = [1, 0] inner_dims_pos = [1, 0] inner_tiles = [8, 8] into %0 : tensor<128x128xf32> -> tensor<16x16x8x8xf32> 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             932:  %1 = tensor.empty() : tensor<128x128xf32> 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             933:  %unpack = linalg.unpack %pack inner_dims_pos = [0, 1] inner_tiles = [8, 8] into %1 : tensor<16x16x8x8xf32> -> tensor<128x128xf32> 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             934:  return %unpack : tensor<128x128xf32> 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |               .
# |               .
# |               .
# |             948: } 
# | check:1732'0     ~~
# |             949:  
# | check:1732'0     ~
# |             950: // ----- 
# | check:1732'0     ~~~~~~~~~
# |             951: // ----- 
# | check:1732'0     ~~~~~~~~~
# |             952: module { 
# | check:1732'0     ~~~~~~~~~
# |             953:  func.func @pack_unpack(%arg0: tensor<16x16x8x8xf32>) -> tensor<16x16x8x8xf32> { 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:1732'1      ?                                                                                possible intended match
# |             954:  return %arg0 : tensor<16x16x8x8xf32> 
# | check:1732'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             955:  } 
# | check:1732'0     ~~~
# |             956: } 
# | check:1732'0     ~~
# |             957:  
# | check:1732'0     ~
# |             958: // ----- 
# | check:1732'0     ~~~~~~~~~
# |               .
# |               .
# |               .
# |            1081:  } 
# |            1082: } 
# |            1083:  
# |            1084: // ----- 
# |            1085: module { 
# |            1086:  func.func @negative_fold_extract_slice_into_unpack_slice_over_non_tiled_dim(%arg0: tensor<30x2x16xf32>, %arg1: tensor<30x32xf32>) -> tensor<28x28xf32> { 
# | label:2119'0                                                                                 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |            1087:  %unpack = linalg.unpack %arg0 inner_dims_pos = [1] inner_tiles = [16] into %arg1 : tensor<30x2x16xf32> -> tensor<30x32xf32> 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            1088:  %extracted_slice = tensor.extract_slice %unpack[0, 0] [28, 28] [1, 1] : tensor<30x32xf32> to tensor<28x28xf32> 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            1089:  return %extracted_slice : tensor<28x28xf32> 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            1090:  } 
# | label:2119'0     ~~~
# |            1091: } 
# | label:2119'0     ~~
# |            1092:  
# | label:2119'0     ~
# |            1093: // ----- 
# | label:2119'0     ~~~~~~~~~
# |            1094: module { 
# | label:2119'0     ~~~~~~~~~
# |            1095:  func.func @negative_fold_extract_slice_into_unpack_slice_over_dynamic_dim(%arg0: tensor<?x2x16xf32>, %arg1: tensor<?x32xf32>, %arg2: index) -> tensor<?x28xf32> { 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | label:2119'1                 ?                                                                                                                                                       possible intended match
# |            1096:  %unpack = linalg.unpack %arg0 inner_dims_pos = [1] inner_tiles = [16] into %arg1 : tensor<?x2x16xf32> -> tensor<?x32xf32> 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            1097:  %extracted_slice = tensor.extract_slice %unpack[0, 0] [%arg2, 28] [1, 1] : tensor<?x32xf32> to tensor<?x28xf32> 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            1098:  return %extracted_slice : tensor<?x28xf32> 
# | label:2119'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            1099:  } 
# | label:2119'0     ~~~
# |            1100: } 
# | label:2119'0     ~~
# |               .
# |               .
# |               .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

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


More information about the Mlir-commits mailing list