[flang-commits] [flang] [Flang] Generate inline reduction loops for elemental count intrinsics (PR #75774)

David Green via flang-commits flang-commits at lists.llvm.org
Wed Dec 20 04:11:27 PST 2023


davemgreen wrote:

> I think creating operations that are legalized by the same pass should work. But you need to create the correct listeners. See
> 
> https://github.com/llvm/llvm-project/blob/9e3d915d8ebf86e24c9ff58766be8e7c6aa7b0c0/flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp#L729
> 
> This makes sure the rest of the pass infrastructure realizes that the new operations were created so that it can then translate them as though they were there at the start of the pass.

Ah, that looks like it would work. That means I could move this to LowerHLFIRIntrinsics if that sounds better. It would be similar code to this, with a name like `tryLowerReductionWithElemental` and called from the existing `CountOpConversion`. It would try the elemental method of lowering, and fall back to the existing libcall if that didn't work. Let me know if that sounds better.

Currently I've updated this to generate the loops in the reversed order.

https://github.com/llvm/llvm-project/pull/75774


More information about the flang-commits mailing list