[Chapel Merge] Do not check for order independence in forall-unor

Branch: refs/heads/master
Revision: b54df66
Author: mppf
Log Message:

Merge pull request #16455 from mppf/fix-unordered-opt-ra-atomics

Do not check for order independence in forall-unordered opt

Resolves https://github.com/Cray/chapel-private/issues/1317
See #12150 for previous discussion of the forall-unordered-opt and its legality.

The forall-unordered opt already only applies to forall loops. This PR
removes an additional check that the loop being optimized (after lowering
iterators) was order independent.

The forall-unordered opt already only applies to forall loops because
the optimization legality checks before iterator lowering (where
lifetimes are checked) only add the OptInfo to forall loops. The later
part of the pass which runs after iterator inlining will only optimize
last statements that are followed by an OptInfo.

As a result, it does not need to check that the forall loop only
contained order-independent code. If the last statement came from a
follower loop, that last statement won’t be marked with OptInfo (because
it wasn’t present in the forall loop before iterator inlining) and the
optimization will fail. If the last statement came from the original
forall loop then the order-independent-ness of the iterator follower
loops is irrelevant - since the author of the original forall loop
indicated it was order independent and the code being delayed is from
that loop.

Adds some tests of patterns along these lines to verify that they are
optimized (or not) as expected.

Reviewed by @ronawho - thanks!

  • [x] full futures local testing

Modified Files:
M compiler/optimizations/optimizeForallUnorderedOps.cpp
M test/optimizations/forall-unordered-opt/compilation-tests/opt-expected.chpl
M test/optimizations/forall-unordered-opt/compilation-tests/opt-expected.good
M test/optimizations/forall-unordered-opt/compilation-tests/opt-unexpected.chpl
M test/release/examples/benchmarks/hpcc/ra-atomics.compopts
M test/release/examples/benchmarks/hpcc/ra-atomics.good

Compare: https://github.com/chapel-lang/chapel/compare/9cc0b53294ab...b54df66be318