[all-commits] [llvm/llvm-project] f2e42d: [mlir][IntRangeInference] Handle ceildivsi(INT_MIN...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Fri Nov 15 09:43:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f2e42d9324f488ef113b8d2157f52ef1699b95f9
      https://github.com/llvm/llvm-project/commit/f2e42d9324f488ef113b8d2157f52ef1699b95f9
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2024-11-15 (Fri, 15 Nov 2024)

  Changed paths:
    M mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
    M mlir/test/Dialect/Arith/int-range-interface.mlir

  Log Message:
  -----------
  [mlir][IntRangeInference] Handle ceildivsi(INT_MIN, x > 1) as expected (#116284)

Fixes #115293

While the definition of ceildivsi is integer division, rounding up, most
implementations will use `-(-a / b)` for dividing `a ceildiv b` with `a`
negative and `b` positive.

Mathematically, and for most integers, these two definitions are
equivalent. However, with `a == INT_MIN`, the initial negation is a
noop, which means that, while divinding and rounding up would give a
negative result, `-((- INT_MIN) / b)` is `-(INT_MIN / b)`, which is
positive.

This commit adds a special case to ceilDivSI inference to handle this
case and bring it in line with the operational instead of the
mathematical semantics of ceiling division.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list