[all-commits] [llvm/llvm-project] 223d3d: [Flang] Minloc elemental intrinsic lowering (#74828)

David Green via All-commits all-commits at lists.llvm.org
Thu Jan 25 04:17:24 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 223d3dabc8b75a75276ef0544132ba0df4498fb3
      https://github.com/llvm/llvm-project/commit/223d3dabc8b75a75276ef0544132ba0df4498fb3
  Author: David Green <david.green at arm.com>
  Date:   2024-01-25 (Thu, 25 Jan 2024)

  Changed paths:
    M flang/include/flang/Optimizer/Support/Utils.h
    M flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp
    M flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
    A flang/test/HLFIR/minloc-elemental.fir
    M flang/test/Transforms/simplifyintrinsics.fir

  Log Message:
  -----------
  [Flang] Minloc elemental intrinsic lowering (#74828)

Currently the lowering of a minloc intrinsic with a mask will look something
like:
  %e = hlfir.elemental %shape ({
    ...
  })
  %m = hlfir.minloc %array mask %e
  hlfir.assign %m to %result
  hlfir.destroy %m
The elemental will be expanded into a temporary+loop, the minloc into a
FortranAMinloc call (which hopefully gets simplified to a specialized call that
can be inlined at the call site), and the assign might get expanded to a
FortranAAssign. It would be better to generate the entire construct as single
loop if we can - one that performs the minloc calculation with the mask
elemental computed inline.

This patch attempt to do that, adding a hlfir version of the expansion code
from SimplifyIntrinsics that turns an minloc+elemental into a single combined
loop nest. It attempts to reuse the methods in genMinlocReductionLoop for
constructing the loop with a modified loop body. The declaration for the
function is currently in Optimizer/Support/Utils.h, but there might be a better
place for it.

It is added as part of the OptimizedBufferizationPass, like the
similar count/any/all that have been added recently.




More information about the All-commits mailing list