jeanPerier wrote:

>  I believe the optimization issues I’m encountering will very likely also 
> appear in the ClangIR project. To avoid duplicated work, I prefer 
> implementing these optimization efforts within the MLIR standard 
> dialects—it’s more general.

While I agree that leveraging the existing memref infra makes sense, and as 
@rscottmanley mentioned, we are actually also working on enabling converting 
part of FIR to MLIR memref/scf, I think the more generic MLIR optimizations 
passes are the one that are dialect independent and relies on interfaces.

Would you be able to implement the optimizations you have in mind via 
interfaces instead of binding them the the memref dialect?

FIR will benefit from running mem2reg earlier even for Fortran specific passes 
(e.g., solving POINTER association before lowering the related assignment and 
expressions when the pointer assignments are visible). So solving the 
fir.declare would be a great help.

Also, I do think that with the 1-to-N conversion pass, we could now get rid of 
fir.cg and win in terms of complexity and compilation time, so I am not very 
inclined into having fir.cg be the starting point (I know the debug info is 
using it, and it should not be a big deal to move it up to operate at the fir 
level).

Hence we are working on making available the work we have that operates at the 
FIR level. It is taking a bit of time since it was not on the top of our list, 
but we have started pushing patches going into that direction [like this 
one](https://github.com/llvm/llvm-project/pull/172117). We think that what we 
have should allow you to convert even more cases to memref (not only arrays 
with static shapes).

I would more than welcome some help to enable the mem2reg with fir.delcare, I 
think what is needed is a fir.declare_value that can be used to keep track of 
the promoted values (very similar to what is done for 
[llvm.dbg.declare](https://github.com/llvm/llvm-project/blob/6e01ea4babc8b5f41cc1541ab73af4388b1744f3/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td#L710))
 so that we can later emit debug info for it in the DebugInfo pass. Would you 
be interested to work on this?

https://github.com/llvm/llvm-project/pull/168703
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to