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] Missed optimization for select a%2==0, (a/2*2)*(a/2*2), 0 #71533

Open
XChy opened this issue Nov 7, 2023 · 5 comments · May be fixed by #92658
Open

[InstCombine] Missed optimization for select a%2==0, (a/2*2)*(a/2*2), 0 #71533

XChy opened this issue Nov 7, 2023 · 5 comments · May be fixed by #92658

Comments

@XChy
Copy link
Member

XChy commented Nov 7, 2023

When I played with InstCombine, I generated something missed-optimized.
No real-world motivation, but it seems to be easy to implement.
Missed example.
Proof.

@XChy XChy changed the title [InstCombine] Missed optimization for select a%2, (a/2*2)*(a/2*2), 0 [InstCombine] Missed optimization for select a%2==0, (a/2*2)*(a/2*2), 0 Nov 7, 2023
@jf-botto
Copy link

jf-botto commented Nov 8, 2023

I'd love to work on this if possible?

@XChy
Copy link
Member Author

XChy commented Nov 8, 2023

I'd love to work on this if possible?

Sure, thanks for contribution.

@nikic
Copy link
Contributor

nikic commented Nov 11, 2023

Note that the mul here isn't really relevant. Here is a simpler pattern that is also missed: https://alive2.llvm.org/ce/z/dYwE-Q

The general issue is making use of KnownBits information inside select arms.

@jf-botto
Copy link

Thank you @nikic,
So what you're saying is, the fix for this is optimising the RHS/LHS of a select by taking into consideration any KnownBits that can be inferred from the condition of the select?

@jf-botto
Copy link

jf-botto commented Dec 1, 2023

Making good progress on this, just have some edge cases that need tidying up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants