cda-group / arc

Programming Language for Continuous Deep Analytics
https://cda-group.github.io/arc/
44 stars 6 forks source link

rust-mlir: Lowering of arith.cmpi "eq"/"ne" for i1 #395

Closed frej closed 2 years ago

frej commented 2 years ago

Since we don't have not in MLIR, I could probably generate not X as X == false or X != true.

We have not, it's just not spelled "not", if you want a truth value and not use flow-control you can use xor:

func @not_i1(%arg0: i1) -> i1 {
  %0 = arith.constant 1 : i1
  %1 = arith.xori %arg0, %0 : i1
  return %1 : i1
}

or you can use select:

func @not_select_i1(%arg0: i1) -> i1 {
  %0 = arith.constant 0 : i1
  %1 = arith.constant 1 : i1
  %2 = arith.select %arg0, %0, %1 : i1
  return %2 : i1
}

check #396.