cornell-zhang/hcl-dialect

[Op] Support logical OR operation

Opened this issue · 0 comments

Logical AND is easy to implement using affine sets, but there are no corresponding operations in MLIR to write logical OR expressions in if condition. Considering if (cond1 || cond2) foo();, there are two possible solutions to rewrite:

  1. Use cascaded if operation, which requires copying the then block multiple times.
if (cond1) {
  foo();
} else if (cond2) {
  foo();
} else {
  // do nothing
}
  1. Use NOT operation to transform the condition into AND form, but this requires implementing the NOT operation and negating the conditions. The short circuit property also does not preserve #65.
if (!(!cond1 && !cond2))
  foo()