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

x86: Fix redundant compare elimination #7019

Merged
merged 1 commit into from
Jun 12, 2023
Merged

Conversation

BradleyWood
Copy link
Contributor

@BradleyWood BradleyWood commented Jun 2, 2023

Redundant compare elimination is a code
generation optimization that attempts to drop
redundant compare instructions before a jump.
This can happen when the the previous
instruction sets condition code flags and is
compared with 0. However, some instructions
such as DIV and IDIV can modify these flags
in undefined ways. This commit lets the code
the code generator know that these instructions
may modify condition code flags. In addition,
the code generator should check if the
instruction that modifies these flags belongs
to the expected node.

Fixes: eclipse-openj9/openj9#17496

@BradleyWood
Copy link
Contributor Author

jenkins build all

@BradleyWood BradleyWood marked this pull request as ready for review June 2, 2023 20:36
@BradleyWood
Copy link
Contributor Author

@0xdaryl Can you review?

@0xdaryl
Copy link
Contributor

0xdaryl commented Jun 5, 2023

Can you explain why you restrict the search to only instructions generated from the current node?

Minor nits:

  • first sentence in the commit message needs some work to improve grammar
  • "code-generation" or "code-generator" should be "code generation" or "code generator" throughout for consistency with rest of code base.

@0xdaryl 0xdaryl self-assigned this Jun 5, 2023
@BradleyWood
Copy link
Contributor Author

Can you explain why you restrict the search to only instructions generated from the current node?

Minor nits:

  • first sentence in the commit message needs some work to improve grammar
  • "code-generation" or "code-generator" should be "code generation" or "code generator" throughout for consistency with rest of code base.

node in this case is the node (such as sub or add) that we expect to have set the condition code flags. If any other instructions set those flags and do not belong to that node, removing the comparison would not make sense.

Redundant compare elimination is a code
generation optimization that attempts to drop
redundant compare instructions before a jump.
This can happen when the the previous
instruction sets condition code flags and is
compared with 0. However, some instructions
such as DIV and IDIV can modify these flags
in undefined ways. This commit lets the code
the code generator know that these instructions
may modify condition code flags. In addition,
the code generator should check if the
instruction that modifies these flags belongs
to the expected node.

Fixes: eclipse-openj9/openj9#17496

Signed-off-by: Bradley Wood <bradley.wood@ibm.com>
@BradleyWood
Copy link
Contributor Author

Changed commit message

@0xdaryl
Copy link
Contributor

0xdaryl commented Jun 12, 2023

Jenkins build xlinux,osx,win

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.

Incorrect evaluation of x>=0
2 participants