[all-commits] [llvm/llvm-project] 18ad80: [mlir][spirv] Improve integer cast during type con...

Lei Zhang via All-commits all-commits at lists.llvm.org
Wed Jul 12 14:38:29 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 18ad80ea6f69879b7ada4089de259553917e5166
      https://github.com/llvm/llvm-project/commit/18ad80ea6f69879b7ada4089de259553917e5166
  Author: Lei Zhang <antiagainst at google.com>
  Date:   2023-07-12 (Wed, 12 Jul 2023)

  Changed paths:
    M mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
    M mlir/lib/Conversion/ComplexToSPIRV/ComplexToSPIRVPass.cpp
    M mlir/lib/Conversion/MathToSPIRV/MathToSPIRVPass.cpp
    M mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp
    M mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRVPass.cpp
    M mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRVPass.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
    M mlir/test/Conversion/MemRefToSPIRV/memref-to-spirv.mlir

  Log Message:
  -----------
  [mlir][spirv] Improve integer cast during type conversion

In SPIR-V, the capabilities for storage and compute are separate.
We have good handling of the storage side in general via MemRef
type conversion and various `memref` dialect ops.

Once the value was loaded properly, if the compute capability is
supported directly, we don't need to emulate like the storage side
with int32. However, we do need to make sure casting ops are
properly inserted to chain the flow to go back to the original
bitwidth.

Right now that is done in the each individual pattern directly,
which put lots of pressure that shouldn't be on the patterns and
causes duplication and trickiness w.r.t. capability check and such.

Instead, we should handle such casting within the SPIR-V conversion
framework using `addSourceMaterialization`, where we can check with
the target environment to make sure the corresponding compute
capability is allowed and then we can materialize and SPIR-V casting
op.

Along the way, we can drop all the duplicated cast materialization
registration in various places.

Reviewed By: kuhar

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




More information about the All-commits mailing list