[flang] Clarify CheckReductionDIM()
authorPeter Klausler <pklausler@nvidia.com>
Wed, 3 Aug 2022 19:22:42 +0000 (12:22 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Tue, 9 Aug 2022 12:51:45 +0000 (05:51 -0700)
commit9d084982a38526fb8ba15867ecceec3e9b82a6f8
treec2565372a1ff412a992fa3a3e56e641a64a82074
parent1d1a56929b725f9a79d98877f12d0a14f8418b38
[flang] Clarify CheckReductionDIM()

This utility routine in constant folding should return false when
a DIM= actual argument to a reduction intrinsic function has a
value that prevents folding, and true when folding can proceed.
The implementation was returning true in cases where a DIM=
argument was present but not constant.

Clarify the code and add commentary: a true result means that
there is no DIM= actual argument present, or that a DIM= argument
exists, is constant, and has a value that is in range.

Differential Revision: https://reviews.llvm.org/D131101
flang/lib/Evaluate/fold-reduction.cpp
flang/lib/Evaluate/fold-reduction.h