NexMing wrote:

> We have a pass that converts FIR to MemRef. It can handle conversion of FIR 
> allocas, loads, stores to memref for basic types and arrays of basic types 
> via MLIR's TypeConverter interface. We also have this act as a stepping stone 
> to affine, since there is general purpose code that cannot currently be 
> represented by the affine dialect. We run this through nightly testing on 
> gfortran and nag test suites and have found it to be robust (but with TODOs - 
> derived types for example). We are interested in sharing and collaborating on 
> this implementation with the intent to upstream.

Hi @rscottmanley 
I would be very happy to have someone collaborate on this work. This PR is 
experimental, and I don’t yet have a definitive approach for the FIR-to-memref 
type conversion. We can discuss the best solution within this PR, or continue 
the discussion in other PRs after this one is merged.

> We initially tried a pass similar to the one presented here, based on FIRCG, 
> but found it was not suitable for broader optimization. As an example: FIR's 
> alias analysis does not work on FIRCG. For AA to work, we need to track back 
> from MemRef or Affine load/store to the source which, if FIRCG, will lead to 
> conservative optimizations.

The reason I chose FIRCG is that the def-use chain introduced by `fir.declare` 
prevents the `mem2reg` optimization (which also prevents further lifting to 
affine optimizations.), and I haven't found any suitable dialect in the MLIR 
standard dialects to represent it. We need to consider how to handle it before 
FIRCG (Maybe we need to convert to the LLVM dialect earlier?).
Regarding alias analysis, I prefer to propagate the information into the MLIR 
standard dialects (for example by using `memref.distinct_objects` or 
`local_alias_analysis.restrict`) and improve alias analysis at the MLIR 
standard-dialect level. What do you think?

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