[flang-commits] [flang] [flang][OpenMP][HLFIR] Support vector subscripted array sections for DEPEND (PR #133892)
via flang-commits
flang-commits at lists.llvm.org
Tue Apr 22 07:39:42 PDT 2025
jeanPerier wrote:
Sharing the lowering logic would bring more complexity I think. You would need to share the code here https://github.com/llvm/llvm-project/blob/c9eb1ffcfe7cf8c9751afe436a6fcab9cb5b9c9b/flang/lib/Lower/ConvertExprToHLFIR.cpp#L808 somehow.
Splitting the steps seems less complex to me than sharing the generation logic here.
So I think your solution is rather clean, even though it implies generating a temporary hlfir.elemental_addr that is discared (in fact, it is not very different from how hlfir.elemental_addr are transformed into hlfir.elemental [here] (https://github.com/llvm/llvm-project/blob/c9eb1ffcfe7cf8c9751afe436a6fcab9cb5b9c9b/flang/lib/Lower/ConvertExprToHLFIR.cpp#L850C31-L850C71) when they appear outside of LHS).
The extra generation/deletion compile time cost should be quite low, and vector subscripts are not that common anyway.
If we ever feel that we want to avoid IR deletion in lowering for better compiler debugging purposes, I would go for introducing some region based operations to address vector subscripts/transform them to hlfir.elemental, but that seems a bit overkill to me currently (I agree with Slava that it is better to stay away IR deletion in lowering as a general guidance).
My only suggestion would be to contain this hlfir.elemental creation/deletion pattern to ConvertExprToHLFIR.cpp in some kind of `hlfir::Entity genVectorSubscriptedDesignatorFirstElementAddress(SomeExpr, ...)` API to keep the OpenMP code clear from this low level aspects.
Note that an alternative would be to work at the evaluate::Expr level to build the designator of the first element and lower that, have you considered it?
I am not sure that it would be cheaper/less complex (if that code is behind an API, we can easily go one way or the other anyway).
https://github.com/llvm/llvm-project/pull/133892
More information about the flang-commits
mailing list