This is an archive of the discontinued LLVM Phabricator instance.

[flang] UBOUND() edge case: empty dimension
ClosedPublic

Authored by jeanPerier on Mar 22 2022, 11:00 AM.

Details

Summary

Similarly to LBOUND in https://reviews.llvm.org/D121488, UBOUND must
return zero for an empty dimension, no matter the specification
expression.

Add a GetUBOUND method to be used in expression rewrite that prevents
folding UBOUND to a bound specification expression if the extent is
not a compile time constant.

Fold the case where the extents is known to be zero (and also deal with
this case in LBOUND since we can and should to comply with constant
expression requirements).

Diff Detail

Event Timeline

jeanPerier created this revision.Mar 22 2022, 11:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 11:00 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
jeanPerier requested review of this revision.Mar 22 2022, 11:00 AM
klausler added inline comments.Mar 22 2022, 11:06 AM
flang/lib/Evaluate/shape.cpp
576

I think that I removed the loop from what became GetLBOUND; if so, perhaps you can do so here too.

Remove useless loop in GetUBOUND and GetRawUpperBound.

jeanPerier marked an inline comment as done.Mar 23 2022, 2:36 AM
klausler accepted this revision.Mar 23 2022, 8:54 AM
This revision is now accepted and ready to land.Mar 23 2022, 8:54 AM
This revision was automatically updated to reflect the committed changes.