Issue 114300
Summary [MLIR][Memref] Code block emptied After `--canonicalize` Pass
Labels mlir
Assignees
Reporter tavakkoliamirmohammad
    Hi, I’m facing an issue with the following code. After applying the `—canonicalize` option, the main function body becomes empty, eliminating all its operations.

You can view the code and reproduction steps in Compiler Explorer: https://godbolt.org/z/s5oKx48Kq

```
module {
  func.func @main() {
    %c8_i32 = arith.constant 8 : i32
    %c1_i32 = arith.constant 1 : i32
    %0 = arith.muli %c1_i32, %c8_i32 : i32
    %alloc = memref.alloc() : memref<64xf32>
    %alloc_0 = memref.alloc() : memref<64xf32>
    affine.for %arg0 = 0 to 64 {
      %1 = arith.index_cast %arg0 : index to i32
      %2 = arith.divui %1, %c1_i32 : i32
      %3 = arith.divui %2, %0 : i32
      %4 = arith.remui %2, %0 : i32
      %5 = arith.divui %4, %c1_i32 : i32
      %c0_i32 = arith.constant 0 : i32
      %6 = arith.muli %c1_i32, %3 : i32
      %7 = arith.muli %c1_i32, %5 : i32
      %8 = arith.addi %c0_i32, %6 : i32
      %9 = arith.addi %c0_i32, %7 : i32
      %10 = arith.muli %8, %0 : i32
      %11 = arith.addi %c0_i32, %10 : i32
      %12 = arith.muli %9, %c1_i32 : i32
      %13 = arith.addi %11, %12 : i32
      %14 = arith.muli %13, %c1_i32 : i32
      %15 = arith.addi %c0_i32, %14 : i32
      %16 = arith.index_cast %15 : i32 to index
      %17 = memref.load %alloc_0[%16] : memref<64xf32>
      %18 = arith.muli %9, %0 : i32
      %19 = arith.addi %c0_i32, %18 : i32
      %20 = arith.muli %8, %c1_i32 : i32
      %21 = arith.addi %19, %20 : i32
      %22 = arith.muli %21, %c1_i32 : i32
      %23 = arith.addi %c0_i32, %22 : i32
      %24 = arith.index_cast %23 : i32 to index
      memref.store %17, %alloc[%24] : memref<64xf32>
    }
    memref.dealloc %alloc : memref<64xf32>
    memref.dealloc %alloc_0 : memref<64xf32>
    return
  }
}
```
Calling the `--canonicalize`
```
module {
  func.func @main() {
    return
  }
}
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to