[mlir][scf] scf-parallel-loop-tiling with no-min-max-bounds=true produces incorrect results
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The no-min-max-bounds=true code path of scf-parallel-loop-tiling appears to
produce incorrect results.
The default affine.min-based tiling path produces the expected output,
while enabling no-min-max-bounds=true results in incorrect execution.
reproducer
```mlir
module {
func.func private @printMemrefI32(tensor<*xi32>)
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%7 = "tosa.const"() <{values = dense<6220> : tensor<1x6x6xi32>}> : () -> tensor<1x6x6xi32>
%9 = "tosa.const"() <{values = dense<-298> : tensor<1x6x6xi32>}> : () -> tensor<1x6x6xi32>
%51 = tosa.bitwise_or %7, %9 : (tensor<1x6x6xi32>, tensor<1x6x6xi32>) -> tensor<1x6x6xi32>
%cast = tensor.cast %51 : tensor<1x6x6xi32> to tensor<*xi32>
call @printMemrefI32(%cast) : (tensor<*xi32>) -> ()
return
}
}
```
`/wrk/open_contributions/llvm-project/build/bin/mlir-opt test2.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | /wrk/open_contributions/llvm-project/build/bin/mlir-opt -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-parallel-loops -convert-index-to-llvm -convert-arith-to-llvm --scf-parallel-loop-tiling="parallel-loop-tile-sizes=1,4 no-min-max-bounds=true" --canonicalize --scf-parallel-loop-tiling="parallel-loop-tile-sizes=1,4 no-min-max-bounds=true" -convert-scf-to-cf -convert-arith-to-llvm -convert-cf-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -lower-affine -convert-arith-to-llvm -reconcile-unrealized-casts | timeout 10 /wrk/open_contributions/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void --shared-libs=/wrk/open_contributions/llvm-project/build/lib/libmlir_c_runner_utils.so --shared-libs=/wrk/open_contributions/llvm-project/build/lib/libmlir_runner_utils.so --shared-libs=/wrk/open_contributions/llvm-project/build/lib/libmlir_async_runtime.so`
with no-min-max-bounds=true
output
```
[[[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[0, 0, 0, 0, 0, 0],
[0, 0, 2, 0, 0, 0]]]
```
with no-min-max-bounds=false correct output
```
[[[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290],
[-290, -290, -290, -290, -290, -290]]]
```
I see a different lowering with no-min-max-bounds=true in /wrk/open_contributions/llvm-project/mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp
Contributor guide
Research direction
Reproduce the issue with the provided mlir-opt and mlir-runner pipeline, then compare the generated lowering for both values of no-min-max-bounds. Start in mlir/lib/Dialect/SCF/Transforms/ParallelLoopTiling.cpp, focusing on the no-min-max-bounds path. Done means the flag produces the same correct tensor output as the affine.min-based path, with a regression test covering the reproducer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100