Skip to content

[mlir] Inconsistent results for affine.apply #114654

@AnonymousBugreporter1

Description

@AnonymousBugreporter1

I have the following MLIR program:
test.mlir:

#map2 = affine_map<(d0, d1) -> (((d1 - (d1 + 2)) floordiv 8) mod 8)>

module {
  func.func nested @func1() -> f32 {
    %idx1 = arith.constant 1 : index
    %res2 = affine.apply #map2(%idx1, %idx1)
    vector.print %res2 : index
    %0 = arith.index_cast %res2 : index to i64
    %1 = arith.sitofp %0 : i64 to f32
    return %1 : f32
  }
}

When I ran /data/tmp/v1102/llvm-project/build/bin/mlir-opt --lower-affine --convert-arith-to-llvm --convert-vector-to-llvm --convert-func-to-llvm --convert-index-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1102/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1102/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1102/llvm-project/build/lib/libmlir_c_runner_utils.so on the program, I got the result of:

7
7.000000e+00

However, when I ran /data/tmp/v1102/llvm-project/build/bin/mlir-opt --affine-simplify-structures --lower-affine --convert-arith-to-llvm --convert-vector-to-llvm --convert-func-to-llvm --convert-index-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1102/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1102/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1102/llvm-project/build/lib/libmlir_c_runner_utils.so on the program, I got the result of:

8
8.000000e+00

The above two results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.

My git version is 33bdb53.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions