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.

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 <[email protected]>
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 <[email protected]>
@hzongaro hzongaro force-pushed the enable-boolean-store-disable-other-cfg-simplifications branch from 4180259 to 6637ba7 Compare October 29, 2025 02:30
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 <[email protected]>
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.

1 participant