[all-commits] [llvm/llvm-project] bf7c49: [mlir][Vector] Add a rewrite pattern for better lo...

Nicolas Vasilache via All-commits all-commits at lists.llvm.org
Mon Sep 18 06:08:31 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bf7c490ab73a22620c3d7790c09bfb11b669e51b
      https://github.com/llvm/llvm-project/commit/bf7c490ab73a22620c3d7790c09bfb11b669e51b
  Author: Nicolas Vasilache <nicolasvasilache at users.noreply.github.com>
  Date:   2023-09-18 (Mon, 18 Sep 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.td
    M mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h
    M mlir/include/mlir/IR/BuiltinTypes.h
    M mlir/lib/Dialect/Vector/TransformOps/VectorTransformOps.cpp
    M mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
    A mlir/test/Dialect/Vector/vector-rewrite-narrow-types.mlir
    A mlir/test/Integration/Dialect/Vector/CPU/test-rewrite-narrow-types.mlir

  Log Message:
  -----------
  [mlir][Vector] Add a rewrite pattern for better low-precision bitcast… (#66387)

…(trunci) expansion

This revision adds a rewrite for sequences of vector `bitcast(trunci)`
to use a more efficient sequence of vector operations comprising
`shuffle` and `bitwise` ops.

Such patterns appear naturally when writing quantization /
dequantization functionality with the vector dialect.

The rewrite performs a simple enumeration of each of the bits in the
result vector and determines its provenance in the pre-trunci vector.
The enumeration is used to generate the proper sequence of `shuffle`,
`andi`, `ori` followed by an optional final `trunci`/`extui`.

The rewrite currently only applies to 1-D non-scalable vectors and bails
out if the final vector element type is not a multiple of 8. This is a
failsafe heuristic determined empirically: if the resulting type is not
an even number of bytes, further complexities arise that are not
improved by this pattern: the heavy lifting still needs to be done by
LLVM.




More information about the All-commits mailing list