[all-commits] [llvm/llvm-project] 1350c9: [mlir] Add integer range inference analysis

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Thu Jun 2 13:24:25 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1350c9887dca5ba80af8e3c1e61b29d6696eb240
      https://github.com/llvm/llvm-project/commit/1350c9887dca5ba80af8e3c1e61b29d6696eb240
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2022-06-02 (Thu, 02 Jun 2022)

  Changed paths:
    A mlir/include/mlir/Analysis/IntRangeAnalysis.h
    M mlir/include/mlir/Interfaces/CMakeLists.txt
    A mlir/include/mlir/Interfaces/InferIntRangeInterface.h
    A mlir/include/mlir/Interfaces/InferIntRangeInterface.td
    M mlir/lib/Analysis/CMakeLists.txt
    M mlir/lib/Analysis/DataFlowAnalysis.cpp
    A mlir/lib/Analysis/IntRangeAnalysis.cpp
    M mlir/lib/Interfaces/CMakeLists.txt
    A mlir/lib/Interfaces/InferIntRangeInterface.cpp
    A mlir/test/Interfaces/InferIntRangeInterface/infer-int-range-test-ops.mlir
    M mlir/test/lib/Dialect/Test/CMakeLists.txt
    M mlir/test/lib/Dialect/Test/TestDialect.cpp
    M mlir/test/lib/Dialect/Test/TestDialect.h
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/lib/Transforms/CMakeLists.txt
    A mlir/test/lib/Transforms/TestIntRangeInference.cpp
    M mlir/tools/mlir-opt/mlir-opt.cpp
    M mlir/unittests/Interfaces/CMakeLists.txt
    A mlir/unittests/Interfaces/InferIntRangeInterfaceTest.cpp

  Log Message:
  -----------
  [mlir] Add integer range inference analysis

This commit defines a dataflow analysis for integer ranges, which
uses a newly-added InferIntRangeInterface to compute the lower and
upper bounds on the results of an operation from the bounds on the
arguments. The range inference is a flow-insensitive dataflow analysis
that can be used to simplify code, such as by statically identifying
bounds checks that cannot fail in order to eliminate them.

The InferIntRangeInterface has one method, inferResultRanges(), which
takes a vector of inferred ranges for each argument to an op
implementing the interface and a callback allowing the implementation
to define the ranges for each result. These ranges are stored as
ConstantIntRanges, which hold the lower and upper bounds for a
value. Bounds are tracked separately for the signed and unsigned
interpretations of a value, which ensures that the impact of
arithmetic overflows is correctly tracked during the analysis.

The commit also adds a -test-int-range-inference pass to test the
analysis until it is integrated into SCCP or otherwise exposed.

Finally, this commit fixes some bugs relating to the handling of
region iteration arguments and terminators in the data flow analysis
framework.

Depends on D124020

Depends on D124021

Reviewed By: rriddle, Mogball

Differential Revision: https://reviews.llvm.org/D124023




More information about the All-commits mailing list