| Issue |
235030
|
| Summary |
[MLIR][Affine] `affine-loop-unroll` emits invalid IR for a loop with `iter_args`
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
pingshiyu
|
The issue occurs on LLVM 23.1.3.
For the following program `repro.mlir`:
```mlir
#map = affine_map<(d0) -> (d0)>
#set = affine_set<()[s0] : (s0 >= 0)>
module {
func.func @repro(%input: index, %value: i1) -> i1 {
%result = affine.if #set()[%input] -> i1 {
affine.yield %value : i1
} else {
%loop = affine.for %iv = 0 to #map(%input) step 2 iter_args(%carried = %input) -> (index) {
%_one_ = arith.constant 1 : index
affine.yield %input : index
}
affine.yield %value : i1
}
return %result : i1
}
}
```
The above program verifies as is:
```console
$ mlir-opt repro.mlir --verify-each -o /dev/null
```
However, when we run the `affine-loop-unroll` pass:
```console
$ mlir-opt repro.mlir \
'--pass-pipeline=builtin.module(func.func(affine-loop-unroll{unroll-factor=2}))' \
--verify-each -o /dev/null
```
The pass errors:
```text
error: 'affine.for' op operand cannot be used as a dimension id
```
The same failure occurs with `unroll-factor=4`.
However, pass should preserve the validity of the IR.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs