This is an archive of the discontinued LLVM Phabricator instance.

[flang][openacc] Support array section with constant lb or ub for data operand
ClosedPublic

Authored by clementval on Apr 19 2023, 3:10 PM.

Details

Summary

Add support for array section with constant lower or upper bound.
The current lowering will trigger a TODO when the array is assumed size
or if the lower or upper bound is a variable.

Depends on D148721

Diff Detail

Event Timeline

clementval created this revision.Apr 19 2023, 3:10 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
clementval requested review of this revision.Apr 19 2023, 3:10 PM
razvanlupusoru accepted this revision.Apr 19 2023, 4:12 PM

Nice! This looks great!

This revision is now accepted and ready to land.Apr 19 2023, 4:12 PM
jeanPerier accepted this revision.Apr 20 2023, 2:59 AM

Few questions, looks good to me otherwise.

flang/lib/Lower/OpenACC.cpp
121

Isn't it possible to extract the Expr<SomeType> at that from lower and to lower that to cover all cases, or do you need to do something special for the constant bounds case?

156

Why not using the symbol map to retrieve the upper bound value? Outside of the compile time constant shape case, the upper bound cannot be retrieved from the Symbol shape at that point.

Special casing the constant upper bounds makes some sense, to avoid the "ub = extent + lb -1" computation, in the generated IR but MLIR folds that easily if the extent and lb are constants.

161

Should there be a TODO if ubound is not set after that (to cover assumed shapes, allocatable, pointers and explicit shape with non constant bounds).

clementval added inline comments.Apr 20 2023, 8:54 AM
flang/lib/Lower/OpenACC.cpp
121

It is just for cosmetic reason.

156

Good point. I'll update that.

161

They should be caught by the TODO in createOpAndAddOperand.

Add extent when upper bound is not available

clementval marked 3 inline comments as done.Apr 20 2023, 10:23 AM
jeanPerier added inline comments.Apr 21 2023, 2:10 AM
flang/lib/Lower/OpenACC.cpp
121

OK, thanks for explaining.