Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems in handling of summation reduction and invariant expressions in Expressions Simplification #6747

Conversation

hzongaro
Copy link
Member

@hzongaro hzongaro commented Oct 3, 2022

This pull request fixes two problem in Expressions Simplification.

  1. In considering whether expressions are invariant and can be pulled out of a loop, TR_ExpressionsSimplification::removeUncertainBlocks checks whether blocks will be executed exactly once within each iteration of the loop, and if not, it removes them from consideration. It does this by checking whether the block post-dominates the entry block for the loop. However, if a block is in another loop nested within the loop, it might post-dominate the entry but still be executed more than once in each iteration of the outer loop. Such blocks must also be removed from consideration.
  2. Expressions Simplification tracks candidates for summation reduction transformation and invariant expression transformation in a list of TR::TreeTop pointers. It later iterates over the candidates, and in checking whether it's working with a summation reduction candidate, it simply checks whether the first child operation of the store is one of iadd, isub, ixor or ineg. However, a candidate for an invariant expression transformation might also have one of those operations as the first child of its store operation. This can result in an invariant expression candidate being transformed as if it had been summation reduction candidate.

    Fixed this by changing the list of candidate TR::TreeTop pointers into a list of SimplificationCandidateTuple objects that contain the candidate TR::TreeTop along with flags indicating the kind of candidate it is.

Fixes eclipse-openj9/openj9#15306

In considering whether to pull an invariant expression out of a loop,
removeUncertainBlocks needs to verify that blocks that are being
considered will be executed exactly once within the region that contains
them.  If a block is nested within another loop in the region, it might
be executed more or less than one time, and so should be removed from
consideration.

Also removed some stray tab characters.
@hzongaro hzongaro marked this pull request as ready for review October 4, 2022 12:52
@hzongaro
Copy link
Member Author

hzongaro commented Oct 4, 2022

Devin @jdmpapin and Vijay @vijaysun-omr, may I ask you to review this change?

@vijaysun-omr
Copy link
Contributor

Jenkins build all

@vijaysun-omr vijaysun-omr self-assigned this Oct 5, 2022
@vijaysun-omr
Copy link
Contributor

I will wait for @jdmpapin review before considering this for merging.

Expressions Simplification looks for summation reductions and invariant
expressions that can be pulled out of loops.  Each instance is tracked
by placing the TR::TreeTop of the candidate in a TR::List.  However, in
the process of actually performing the transformation, <some method>
doesn't perform the same checking of a summation reduction as it does
during the initial analysis.  In particular, an invariant expression
that happens to involve an ineg, ixor, isub or iadd might end up being
transformed as if it was a summation reduction.

Fixed this by using a list of candidates that carries a flag indicating
the kind of transformation that can be performed along with the
TR::TreeTop.
@hzongaro hzongaro force-pushed the issue-15534-expr-simplification-loop-invariant branch from 7f4dd02 to 5975854 Compare October 11, 2022 17:40
@hzongaro
Copy link
Member Author

Squashed trace message change in commit 5975854. No other changes.

@jdmpapin
Copy link
Contributor

All checks passed for the revision that Vijay approved. The only difference between that revision and the current one is from 7f4dd02 (now squashed), which only affects tracing, so I think that once the current builds pass, this is fine to merge without another "build all."

@vijaysun-omr
Copy link
Contributor

Thanks, as mentioned the only change is in the area of tracing and since basic/build checks have now passed, I am merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDK8 OpenJ9 Gives Different Results from HotSpot and Android Runtime
3 participants