1. Mar 23, 2024
    • Matthias Springer's avatar
      [mlir][Arith] `ValueBoundsOpInterface`: Support `arith.select` · 680d04d7
      Matthias Springer authored
      This commit adds a `ValueBoundsOpInterface` implementation for `arith.select`. The implementation is almost identical to `scf.if` (#85895), but there is one special case: if the condition is a shaped value, the selection is applied element-wise and the result shape can be inferred from either operand.
      680d04d7
    • Matthias Springer's avatar
      [mlir][SCF][NFC] `ValueBoundsConstraintSet`: Simplify `scf.for` implementation · 3c4adb54
      Matthias Springer authored
      This commit simplifies the implementation of the `ValueBoundsOpInterface` for `scf.for` based on the newly added `ValueBoundsConstraintSet::compare` API and adds additional documentation.
      
      Previously, the interface implementation created a new constraint set just to check if the yielded value and iter_arg are equal. This was inefficient because constraints were added multiple times (to two different constraint sets) for ops that are inside the loop.
      3c4adb54
    • Matthias Springer's avatar
      [mlir][SCF] `ValueBoundsConstraintSet`: Support preliminary support for branches · b4bab14a
      Matthias Springer authored
      This commit adds support for `scf.if` to `ValueBoundsConstraintSet`.
      
      Example:
      ```
      %0 = scf.if ... -> index {
        scf.yield %a : index
      } else {
        scf.yield %b : index
      }
      ```
      
      The following constraints hold for %0:
      * %0 >= min(%a, %b)
      * %0 <= max(%a, %b)
      
      Such constraints cannot be added to the constraint set; min/max is not supported by `IntegerRelation`. However, if we know which one of %a and %b is larger, we can add constraints for %0. E.g., if %a <= %b:
      * %0 >= %a
      * %0 <= %b
      
      This commit required a few minor changes to the `ValueBoundsConstraintSet` infrastructure, so that values can be compared while we are still in the process of traversing the IR/adding constraints.
      b4bab14a
    • Matthias Springer's avatar
      [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Pass stop condition in the constructor · ad1b2ac4
      Matthias Springer authored
      This commit changes the API of `ValueBoundsConstraintSet`: the stop condition is now passed to the constructor instead of `processWorklist`. That makes it easier to add items to the worklist multiple times and process them in a consistent manner. The current `ValueBoundsConstraintSet` is passed as a reference to the stop function, so that the stop function can be defined before the the `ValueBoundsConstraintSet` is constructed.
      
      This change is in preparation of adding support for branches.
      ad1b2ac4
    • Matthias Springer's avatar
      [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Delete dead code · f9442791
      Matthias Springer authored
      There is an assertion that the stop condition is not satisfied for the the starting point at the beginning of `computeBound`. Therefore, that case does not have to be handled later on in that function.
      f9442791
    • Matthias Springer's avatar
      [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Add columns for constant values/dims · 6bbcba6f
      Matthias Springer authored
      `ValueBoundsConstraintSet` maintains an internal constraint set (`IntegerRelation`), where every analyzed index-typed SSA value or dimension of a shaped type is represented with a dimension/symbol. Prior to this change, index-typed values with a statically known constant value and static shaped type dimensions were not added to the constraint set. Instead, `getExpr` directly returned an affine constrant expression.
      
      With this commit, dynamic and static values/dimension sizes are treated in the same way: in either case, a dimension/symbol is added to the constraint set. This is needed for a subsequent commit that adds support for branches.
      6bbcba6f
  2. Mar 22, 2024