Skip to content

Conversation

@hzongaro
Copy link
Contributor

This pull request is comprised of three changes related to the CFG Simplification optimization:

  1. It re-enables the boolean store simplification of CFG Simplifier.

  2. It fixes a bug in boolean store simplification in examining the values used in two stores on both sides of an if-then-else. The code was testing whether either value that was being stored was an internal pointer. However, it got the values of both stores based on whether the first of the two stores was indirect: if it was indirect, the value of the store must be the child at index 1; otherwise, the value of the store must be the child at index 0. However, if the first store was indirect, but the second was direct, it would access a non-existent child of the second store at index 1. Fixed this by delaying retrieving the values until after comparing the opcodes of the two stores for equality, ensuring both are indirect stores or both are direct stores.

  3. Several patterns and corresponding transformations in CFG Simplification have never been fully tested — in particular, simplifyNullToException, simplifySimpleStore, simplifyCondStoreSequence, simplifyInstanceOfTestToCheckcast and simplifyBoundCheckWithThrowException. This change disables those transformations by default, allowing them to be enabled based on the settings of various environment variables. The intention is that they should be more thoroughly tested and then re-enabled as that testing and any necessary bug fixes have been completed.

@hzongaro
Copy link
Contributor Author

Marking this pull request as a draft as it exposes the bug reported in downstream project OpenJ9 issue eclipse-openj9/openj9#22835.

@hzongaro
Copy link
Contributor Author

Rebased to resolve merge conflicts.

@hzongaro hzongaro force-pushed the enable-boolean-store-disable-other-cfg-simplifications branch from d6b795c to baeadad Compare December 11, 2025 22:34
@hzongaro hzongaro marked this pull request as ready for review January 16, 2026 13:39
@hzongaro
Copy link
Contributor Author

@vijaysun-omr, may I ask you to review this change?

if (disableSimplifyExplicitNULLTest != NULL || disableSimplifyNullToException != NULL)
static const char *enableSimplifyExplicitNULLTest = feGetEnv("TR_enableSimplifyExplicitNULLTest");
static const char *enableSimplifyNullToException = feGetEnv("TR_enableSimplifyNullToException");
if (enableSimplifyExplicitNULLTest == NULL || enableSimplifyNullToException == NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this condition be using && instead of || ? In that if either enable is set then we do not return false early ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had debated about whether to use && or ||. If you look at the downstream pull request eclipse-openj9/openj9#22838, I did something similar there. I agree that using && would make things easier for developers to investigate these transformations in the future. I will correct this in both pull requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised in commit ac3dc31

Several patterns and corresponding transformations in CFG Simplification
have never been fully tested - in particular, simplifyNullToException,
simplifySimpleStore, simplifyCondStoreSequence,
simplifyInstanceOfTestToCheckcast and
simplifyBoundCheckWithThrowException.  This change disables those
transformations by default, allowing them to be enabled based on the
settings of various environment variables.  The intention is that they
should be more thoroughly tested and then reenabled as that testing and
any necessary bug fixes have been completed.

This change also fixes some typos in trace messages and changes the
declarations of some pointers that hold the results of calls to
feGetEnv from 'static char *' to 'static const char *' to emphasize
that the strings pointed to will not change.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
The simplifyBooleanStore method of CFG Simplifier was disabled several
years ago.  This change reenables that transformation which had
previously been in use for many years.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
The simplifyBooleanStore method of CFG Simplifier tries to determine
whether two stores in different blocks update the same location based on
a boolean condition.  One of the conditions considers whether either
store is storing an internal pointer.  However, the code only tested
whether the first of the two stores was indirect before deciding whether
the first child or second child of both stores needed to have its
isInternalPointer flag tested.  If the first store was indirect, but the
second was direct, that would result in a non-existent second child of
the second store being accessed.  Similarly, if the first store was
direct, but the second was indirect, the first child of the second store
would be accessed, rather than the child representing the value to be
stored.

This change fixes this problem by moving the code that performs these
tests after a test of whether the two stores use the same opcode value.
At that point, the stores must both be direct stores or both be indirect
stores, so the same child index of each will need to have its
isInternalPointer flag tested.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
@hzongaro hzongaro force-pushed the enable-boolean-store-disable-other-cfg-simplifications branch from baeadad to 7041a26 Compare January 20, 2026 18:46
@vijaysun-omr
Copy link
Contributor

Jenkins build all

@hzongaro
Copy link
Contributor Author

@vijaysun-omr
Copy link
Contributor

Merging since issues are known ones...

@vijaysun-omr vijaysun-omr merged commit 3be72c9 into eclipse-omr:master Jan 21, 2026
11 of 14 checks passed
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.

2 participants