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] Fold (zext (X +nuw C)) + -C --> zext(X) when zext has additional use. #98533

Merged
merged 3 commits into from
Jul 12, 2024

Commits on Jul 11, 2024

  1. [InstCombine] Add additional test case for (add (zext (add nuw X, C2)…

    …, C1). NFC
    
    Add test where the zext has an additional use, but the entire
    expression can be replaced with (zext X). Folding even though there
    is an additional use would not increase the number of instructions.
    topperc committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    971e930 View commit details
    Browse the repository at this point in the history
  2. [InstCombine] Fold (zext (X +nuw C)) + -C --> zext(X) when zext has a…

    …dditional use.
    
    We have a general fold for (zext (X +nuw C2)) + C1 --> zext (X + (C2 + trunc(C1)))
    but this fold is disabled if the zext has an additional use.
    
    If the two constants cancel, we can fold the whole expression to
    zext(X) without increasing the number of instructions.
    
    Though we will have 2 zexts which might be not be cheap. So
    another option could be to move the original narrow add after the zext
    for the other uses. That would allow sharing of the zext(x).
    topperc committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    42fdcf8 View commit details
    Browse the repository at this point in the history

Commits on Jul 12, 2024

  1. Configuration menu
    Copy the full SHA
    4ad5e5c View commit details
    Browse the repository at this point in the history