Skip to content

Inconsistent results when using --arith-unsigned-when-equivalent --int-range-optimizations #82158

@AnonymousBugreporter1

Description

@AnonymousBugreporter1

I have the following MLIR program:
test.mlir:

module {
  func.func @func1() {
    %c8_i32 = arith.constant 8 : i32
    %c29326_i32 = arith.constant 29326 : i32
    %c2_i32 = arith.constant 2 : i32
    %c1_i32 = arith.constant 1 : i32

    %30 = arith.shrsi %c29326_i32, %c2_i32 : i32 // the result should be 7331, which is 1110010100011 of binary
    %47 = math.ctpop %30 : i32 // the result should be 7
    %57 = arith.shli %47, %c1_i32 : i32 // the result should be 14
    %65 = arith.ceildivsi %57, %c8_i32 : i32 // the result should be 2
    vector.print %65 : i32
    return
  }
}

However, when I ran mlir-opt --arith-expand --arith-unsigned-when-equivalent --int-range-optimizations test.mlir on the program, I got the following result:

module {
  func.func @func1() {
    %c-536870910_i32 = arith.constant -536870910 : i32
    vector.print %c-536870910_i32 : i32
    return
  }
}

And when I ran mlir-opt --arith-expand --int-range-optimizations test.mlir on the program, I got the following result:

 module {
  func.func @func1() {
    %c1_i32 = arith.constant 1 : i32
    vector.print %c1_i32 : i32
    return
  }
}

I've tried to analyze my program manually, and my result is that the value of the constant operation seems to be 2, which is different from either of the above results. I'm not sure if there is any bug in my program or some other problems that caused these results.
My git version is 1a8c613.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions