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

Refactor Binary Identity Simplification Macro #7195

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

jmesyou
Copy link
Contributor

@jmesyou jmesyou commented Dec 5, 2023

This commit cleans up the BINARY_IDENTITY_OP and
BIANRY_IDENTITY_OR_ZERO macros and replaces them
with inline equivalents by implementing a struct to replace template
instantions of the functions tryAndSimplifyBinaryOp*.

This change limits the number of template instantiations
potential call sites have to create as well as abstracts
some captured variables inside the struct to minimize
the number of arguments passed to actual calls.

A closure is emulated by the struct.
Through escape analysis, scalar replacement and inlining,
the overhead of creating this struct should be minimal
on -O3

Related: #7166

Signed-off-by: James You [email protected]

@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch 10 times, most recently from 2c1fda2 to f4e05e8 Compare December 12, 2023 18:17
@jmesyou jmesyou marked this pull request as ready for review December 13, 2023 21:48
@jmesyou jmesyou requested review from hzongaro and vijaysun-omr and removed request for vijaysun-omr December 13, 2023 21:49
@hzongaro hzongaro self-assigned this Dec 14, 2023
@hzongaro
Copy link
Contributor

It looks like there are some build errors on Windows and macOS.

D:\a\1\s\compiler\optimizer\OMRSimplifierHandlers.cpp(6550,24): error C2672: 'tryAndSimplifyBinaryIdentityOp': no matching overloaded function found [D:\a\1\s\build\jitbuilder\jitbuilder.vcxproj]
D:\a\1\s\compiler\optimizer\OMRSimplifierHandlers.cpp(6550,7): error C2782: 'TR::Node *tryAndSimplifyBinaryIdentityOp(TR::Simplifier *,T (__cdecl *)(TR::Node *),TR::Node *,T)': template parameter 'T' is ambiguous [D:\a\1\s\build\jitbuilder\jitbuilder.vcxproj]
D:\a\1\s\compiler\optimizer\OMRSimplifierHandlers.cpp(249): message : see declaration of 'tryAndSimplifyBinaryIdentityOp' [D:\a\1\s\build\jitbuilder\jitbuilder.vcxproj]

@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch 2 times, most recently from c8a8d5d to 092686b Compare December 21, 2023 16:25
@jmesyou
Copy link
Contributor Author

jmesyou commented Dec 21, 2023

@hzongaro ready for another look!

@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from 092686b to b901254 Compare January 3, 2024 22:56
@hzongaro
Copy link
Contributor

hzongaro commented Feb 2, 2024

@a7ehuo, I haven't managed to spend the time needed to review this pull request properly. May I ask you to review?

@a7ehuo
Copy link
Contributor

a7ehuo commented Feb 2, 2024

@jmesyou Does the second commit almost rewrite the core change made in the first commit? It might be hard to review since any comment added to the first commit might not be applicable any more after the second commit. And some of the comments might need to refer to the code in the first commit but the suggestion would apply to the second commit since the structure of the design has been changed in the second commit. Could the two commits be squashed into one to make it easier for review? Thank you!

Could the commit comment and the PR description be updated to reflect more accurately on the content since this PR doesn't solve the whole issue but it addresses 2 of the 3 macros mentioned in the issue #7166

Fixes: #7166
=>
Related: #7166

@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch 2 times, most recently from 0664dc2 to 6795c73 Compare February 5, 2024 21:34
@jmesyou
Copy link
Contributor Author

jmesyou commented Feb 5, 2024

@a7ehuo I squashed the commits together. Hopefully that will make the PR and changes easier to read. I've also updated the Fixes messaged to the Related message.

Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

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

Thank you very much for making this change to clean up the code and squashing the two commits! I just have some minor comments.

Meanwhile could the description of this PR be updated with the latest commit message? I'd also recommend running some regression tests such as sanity.functional, extended.functional, or sanity.system, sanity.openjdk etc. on different platforms with this change to make sure there is no regression.

compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch 3 times, most recently from d1827d5 to cbfa9ff Compare February 14, 2024 00:59
@jmesyou jmesyou requested a review from a7ehuo February 14, 2024 17:02
Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

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

Thank you very much for making the update @jmesyou! I just have some minor follow up comments.

compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
@jmesyou jmesyou requested a review from a7ehuo February 24, 2024 00:11
Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

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

Thanks for making the update @jmesyou! I have two comments as below

compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from e9d2b08 to 0152754 Compare February 26, 2024 22:15
Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

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

Thank you for the update!

LGTM. I assume you're running some regression tests (sanity.functional, extended.functional, sanity.openjdk etc). Once you confirm the regression tests complete successfully and all the commits are squashed into one. I'll approve the PR. Thanks again!

@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from 0152754 to 060d4ca Compare February 26, 2024 22:25
@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from 060d4ca to 45ea2ab Compare March 5, 2024 19:37
@jmesyou
Copy link
Contributor Author

jmesyou commented Mar 6, 2024

Internal build 21052 is passing and commits squashed

@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from 45ea2ab to 217a709 Compare March 6, 2024 15:33
Copy link
Contributor

@a7ehuo a7ehuo left a comment

Choose a reason for hiding this comment

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

LGTM . Thank you very much for making the update @jmesyou!

Copy link
Contributor

@hzongaro hzongaro left a comment

Choose a reason for hiding this comment

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

I think the changes look good. I have a number of cosmetic comments, mostly on the existing code.

compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@hzongaro hzongaro left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. All your changes look good - just one further comment. Once addressed, you can go ahead and squash the commits. Thanks!

compiler/optimizer/OMRSimplifierHandlers.cpp Outdated Show resolved Hide resolved
@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from 11dac46 to 0eb4905 Compare March 20, 2024 17:27
Copy link
Contributor

@hzongaro hzongaro left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

@hzongaro
Copy link
Contributor

Jenkins build all

@hzongaro
Copy link
Contributor

It looks like the z/OS and AIX compilers are having trouble with part of these changes.

13:34:33  "/home/omr/workspace/Build/compiler/optimizer/OMRSimplifierHandlers.cpp", line 266.38: 1540-0063 (S) The text "s" is unexpected.
13:34:33  "/home/omr/workspace/Build/compiler/optimizer/OMRSimplifierHandlers.cpp", line 271.39: 1540-0063 (S) The text "s" is unexpected.
13:34:33  "/home/omr/workspace/Build/compiler/optimizer/OMRSimplifierHandlers.cpp", line 276.39: 1540-0063 (S) The text "s" is unexpected.
13:34:33  "/home/omr/workspace/Build/compiler/optimizer/OMRSimplifierHandlers.cpp", line 281.39: 1540-0063 (S) The text "s" is unexpected.
13:34:33  "/home/omr/workspace/Build/compiler/optimizer/OMRSimplifierHandlers.cpp", line 286.40: 1540-0063 (S) The text "s" is unexpected.
13:34:33  "/home/omr/workspace/Build/compiler/optimizer/OMRSimplifierHandlers.cpp", line 291.40: 1540-0063 (S) The text "s" is unexpected.

This commit cleans up the BINARY_IDENTITY_OP and
BIANRY_IDENTITY_OR_ZERO macros and replaces them
with inline equivalents by implementing a struct to replace template
instantions of the functions tryAndSimplifyBinaryOp*.

This change limits the number of template instantiations
potential call sites have to create as well as abstracts
some captured variables inside the struct to minimize
the number of arguments passed to actual calls.

A closure is emulated by the struct.
Through escape analysis, scalar replacement and inlining,
the overhead of creating this struct should be minimal
on -O3

Related: eclipse-omr#7166

Signed-off-by: James You <[email protected]>
@jmesyou jmesyou force-pushed the refactor/binary_identity_op branch from 0eb4905 to 5030f48 Compare March 21, 2024 17:53
@jmesyou
Copy link
Contributor Author

jmesyou commented Mar 21, 2024

@hzongaro had to rebase and force push to run the Jenkins pipeline, sorry about that 😅

@hzongaro
Copy link
Contributor

Jenkins build all

@jmesyou
Copy link
Contributor Author

jmesyou commented Mar 22, 2024

RISV failure looks unrelated, had similar failure yesterday on unrelated PR #7287. MacOS failure known to be #7181

@hzongaro
Copy link
Contributor

RISV failure looks unrelated, had similar failure yesterday on unrelated PR #7287

Opened issue #7291 for the RISC-V failure.

@hzongaro hzongaro merged commit 6391cf4 into eclipse-omr:master Mar 27, 2024
15 of 18 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.

3 participants