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

[InstCombine] Simplify and/or of icmp eq with op replacement #70335

Merged
merged 1 commit into from
Oct 30, 2023

Commits on Oct 27, 2023

  1. [InstCombine] Simplify and/or of icmp eq with op replacement

    and/or in logical (select) form benefit from generic simplifications
    via simplifyWithOpReplaced(). However, the corresponding fold for
    plain and/or currently does not exist.
    
    Similar to selects, there are two general cases for this fold
    (illustrated with `and`, but there are `or` conjugates).
    
    The basic case is something like `(a == b) & c`, where the
    replacement of a with b or b with a inside c allows it to fold
    to true or false. Then the whole operation will fold to either
    false or `a == b`.
    
    The second case is something like `(a != b) & c`, where the
    replacement inside c allows it to fold to false. In that case,
    the operand can be replaced with c, because in the case where
    a == b (and thus the icmp is false), c itself will already be
    false.
    
    As the test diffs show, this catches quite a lot of patterns in
    existing test coverage. I believe this also obsoletes quite a few
    existing special-case and/or of icmp special case folds we have,
    but I haven't removed anything as part of this patch in the
    interest of risk mitigation.
    nikic committed Oct 27, 2023
    Configuration menu
    Copy the full SHA
    8a1d0a6 View commit details
    Browse the repository at this point in the history