[all-commits] [llvm/llvm-project] 66abe6: [flang][hlfir] add an optimized bufferization pass

Tom Eccles via All-commits all-commits at lists.llvm.org
Fri Aug 18 02:53:59 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 66abe644663e84305534b44e035f6fbd383ae81f
      https://github.com/llvm/llvm-project/commit/66abe644663e84305534b44e035f6fbd383ae81f
  Author: Tom Eccles <tom.eccles at arm.com>
  Date:   2023-08-18 (Fri, 18 Aug 2023)

  Changed paths:
    M flang/include/flang/Optimizer/HLFIR/Passes.h
    M flang/include/flang/Optimizer/HLFIR/Passes.td
    M flang/include/flang/Tools/CLOptions.inc
    M flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt
    A flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp
    M flang/test/Fir/basic-program.fir
    A flang/test/HLFIR/opt-bufferization.fir

  Log Message:
  -----------
  [flang][hlfir] add an optimized bufferization pass

This pass is intended to spot cases where we can do better than the
default bufferization and to rewrite those specific cases. Then the
default bufferization (bufferize-hlfir pass) can handle everything else.

The transformation added in this patch rewrites simple element-wise
updates to an array to a do-loop modifying the array in place instead of
creating and assigning an array temporary.

See the RFC at
https://discourse.llvm.org/t/rfc-hlfir-optimized-bufferization-for-elemental-array-updates

This patch gets the improvement to exchange2 but not the improvement to cam4
described in the RFC. I think the cam4 improvement will require better alias
analysis. I aim to follow up to fix this in a later patch. With changes
since the RFC, the pass improves polyhedron channel2 by about 52%.

Depends on: D156805 D157718 D157626

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


  Commit: 05011024fd0a27f54e3fd9c3fb7c42f6a86ab391
      https://github.com/llvm/llvm-project/commit/05011024fd0a27f54e3fd9c3fb7c42f6a86ab391
  Author: Tom Eccles <tom.eccles at arm.com>
  Date:   2023-08-18 (Fri, 18 Aug 2023)

  Changed paths:
    M flang/lib/Optimizer/Transforms/LoopVersioning.cpp
    M flang/test/Transforms/loop-versioning.fir

  Log Message:
  -----------
  [flang][LoopVersioning] support fir.declare

When FIR comes from HLFIR, there will be a fir.declare operation between
the source and the usage of each source variable (and some temporary
allocations). This pass needs to be able to follow these so that it can
still transform loops when HLFIR is used, otherwise it mistakenly
assumes these values are not function arguments.

More work is needed after this patch to fully support HLFIR, because the
generated code tends to use fir.array_coor instead of fir.coordinate_of.

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


Compare: https://github.com/llvm/llvm-project/compare/d2aff81285f2...05011024fd0a


More information about the All-commits mailing list