[all-commits] [llvm/llvm-project] f6df11: [mlir][llvm] add basic type consistency pattern de...

Markus Böck via All-commits all-commits at lists.llvm.org
Wed Jul 5 04:57:32 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f6df11568e83960ef698fc979965428c6b431344
      https://github.com/llvm/llvm-project/commit/f6df11568e83960ef698fc979965428c6b431344
  Author: Markus Böck <markus.bock+llvm at nextsilicon.com>
  Date:   2023-07-05 (Wed, 05 Jul 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
    M mlir/lib/Dialect/LLVMIR/Transforms/TypeConsistency.cpp
    M mlir/test/Dialect/LLVMIR/type-consistency.mlir

  Log Message:
  -----------
  [mlir][llvm] add basic type consistency pattern destructuring stores

This is a common pattern produced by clang and similar.
Essentially, it coalesces stores into adjacent integer fields into a single integer store.
This violates our definition of type-consistency that the pass is supposed to enforce and also prevents SROA and mem2reg from eliminating `alloca`s.

This patch fixes that by splitting these stores into multiple stores.
It does so by simply using logical shift rights and truncating the produced value to the size of the field, optionally bitcasting before storing into the field.

The implementation is currently very simple, only working on struct types of a single depth and adjacent fields in that struct, with no padding inbetween. Future work could improve on these once required.

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




More information about the All-commits mailing list