cornell-zhang/hcl-dialect

[FixedToInt] Add case for arith::SelectOp

Closed this issue · 0 comments

arith::SelectOp was not covered in the --fixed-to-integer pass. A test example for this case:

module {
  func.func @top(%arg0: memref<10x!hcl.Fixed<8, 4>>, %arg1: memref<10x!hcl.Fixed<8, 4>>) attributes {itypes = "__", otypes = ""} {
    affine.for %arg2 = 0 to 10 {
      %0 = affine.load %arg0[%arg2] {from = "tensor_0"} : memref<10x!hcl.Fixed<8, 4>>
      %c0_i32 = arith.constant 0 : i32
      %1 = hcl.fixed_to_fixed(%0) : !hcl.Fixed<8, 4> -> !hcl.Fixed<36, 4>
      %2 = hcl.int_to_fixed(%c0_i32) : i32 -> !hcl.Fixed<36, 4>
      %3 = hcl.cmp_fixed sgt, %1, %2 : !hcl.Fixed<36, 4>
      %4 = affine.load %arg0[%arg2] {from = "tensor_0"} : memref<10x!hcl.Fixed<8, 4>>
      %5 = hcl.int_to_fixed(%c0_i32) : i32 -> !hcl.Fixed<8, 4>
      %6 = arith.select %3, %4, %5 : !hcl.Fixed<8, 4>
      affine.store %6, %arg1[%arg2] {to = "tensor_1"} : memref<10x!hcl.Fixed<8, 4>>
    } {loop_name = "x", op_name = "tensor_1"}
    return
  }
}

hcl-opt %s --fixed-to-integer throws verification error:

loc("-":11:12): error: 'arith.select' op failed to verify that all of {true_value, false_value, result} have same type